问题
So I got a thumb-drive plugged in. Its at /dev/sdb1
. Its got some files on it, and it is mounted. I do
>>> glob.glob("/dev/sdb1/*")
[]
Why is this and what can I do about it?
https://pypi.python.org/pypi/glob2
回答1:
You are globbing on the device file. If you want to access the files, you need to glob on the mount point, which is (depending on your system) probably something like "/run/media/$USER/something", "/media/something" or "/mnt/something", where "something" might be sdb1 or the thumb-drive's partition label.
回答2:
"... and it is mounted."
But it is not mounted on /dev/sdb1
; that is simply its device file. Examine the actual mount point to find the files stored on the drive.
来源:https://stackoverflow.com/questions/35658332/why-cant-python-glob-detect-my-thumbdrive-and-what-can-i-do-about-it