Why can't python glob detect my thumbdrive (and what can I do about it?)

前提是你 提交于 2019-12-12 05:35:12

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!