V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
cshcool
V2EX  ›  Python

Python 如何读取光盘内文件信息

  •  
  •   cshcool · Mar 22, 2013 · 4761 views
    This topic created in 4797 days ago, the information mentioned may be changed or developed.
    需求很简单,就是将光盘内的所有文件名列出,但是用os.listdir函数直接访问光盘的盘符,会出现 代码为234的windows error。

    有看到《可爱的Python》这本书里有专门在介绍关于读取光盘的,但他是在Linux环境下通过os.walk('/media/cdrom0') 来获得光盘内容信息

    工作环境的关系,我只能在windows下完成这个需求,请问有什么方法吗? 谢谢
    3 replies    1970-01-01 08:00:00 +08:00
    Mac
        1
    Mac  
       Mar 22, 2013
    os.walk(r'G:')
    cshcool
        2
    cshcool  
    OP
       Mar 23, 2013
    @Mac 你好,os.walk其他本地磁盘都没问题,就是对光盘的盘符进行os.walk时 没有结果也没报错
    0x0001
        3
    0x0001  
       Mar 23, 2013   ❤️ 1
    可尝试调用cmd的tree命令,我没在Python试过…
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3067 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 52ms · UTC 12:54 · PVG 20:54 · LAX 05:54 · JFK 08:54
    ♥ Do have faith in what you're doing.