How to look what other players inventory contains?

Solution 1:

To look a player inventory:

/data get entity @p Inventory

     

To look a chest inventory:

/data get block 0 0 0 Items

To set a player inventory in a chest and clean his inventory (command block):

execute at @p run data modify block 762 70 1565 Items set from entity @p Inventory 

clear @p

Solution 2:

Provided you are using a multiplayer server, the common (and useful) Essentials plugin comes with an in-build command to view a player's inventory. You can use the /invsee <name> command to achieve this.

You can also modify a users inventory using this command.