#loot is an extended command used to open an unlocked container on the floor. (Containers in your inventory can be opened by applying them.) With the number_pad option on, the l key can be used a single-letter alias for #loot.
Loot is also the general name by which the stuff that you have found is called. It is often used in a context like "In addition to the wand, I found lots of nice loot from the Castle." Useless loot is called junk.
Sometimes looting a container may trigger a trap, such as a poison needle (this only happens if you succeed in opening the box—it will never go off if it's locked). You can use the #untrap command to search the container for traps prior to looting.
Looting other things
The loot command can be used to remove the saddle from a saddled monster.
If you try to loot when there is no container present, you will be told "You don't find anything here to loot." If you are confused, you will instead drop some of your gold and get the message "Ok, now there is loot here."
Attempting to loot a throne while confused generates a throne room monster and deposits a random amount of your gold in its inventory ("The exchequer accepts your contribution"), unless there is a chest on the level, in which case the gold is put in that ("Thank you for your contribution to reduce the debt.") See throne farming.
The configuration option lootabc affects what keyboard shortcuts in the looting menu are available. With lootabc, the options are a - Take something out of the container, b - Put something into the container, or c - Both of the above. Without lootabc, the options use keys o, i, and b respectively.