V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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 · 2013-03-22 20:39:02 +08:00 · 3792 次点击
    这是一个创建于 4057 天前的主题,其中的信息可能已经有所发展或是发生改变。
    需求很简单,就是将光盘内的所有文件名列出,但是用os.listdir函数直接访问光盘的盘符,会出现 代码为234的windows error。

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

    工作环境的关系,我只能在windows下完成这个需求,请问有什么方法吗? 谢谢
    3 条回复    1970-01-01 08:00:00 +08:00
    Mac
        1
    Mac  
       2013-03-22 21:49:16 +08:00
    os.walk(r'G:')
    cshcool
        2
    cshcool  
    OP
       2013-03-23 09:45:32 +08:00
    @Mac 你好,os.walk其他本地磁盘都没问题,就是对光盘的盘符进行os.walk时 没有结果也没报错
    0x0001
        3
    0x0001  
       2013-03-23 09:54:24 +08:00   ❤️ 1
    可尝试调用cmd的tree命令,我没在Python试过…
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2356 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 124ms · UTC 15:36 · PVG 23:36 · LAX 08:36 · JFK 11:36
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.