+ -
当前位置:首页 → 问答吧 → python 中的 open()

python 中的 open()

时间:2011-02-20

来源:互联网

写法是:[code=Pytho]
  f = open('d:/static/logo/logo.gif', 'wb')    ---不对
  f = open('static/logo/logo.gif', 'wb')        ---不对
  f = open('static/logo/logo.gif', 'wb')        ---不对[/code]

总是提示 no such file or directory?
open 不是自动创建文件么?

作者: zhangweiwindow   发布时间: 2011-02-20

只会创建文件,不会创建目录。如果d:/static/logo/不存在,应该就会出错。

作者: iambic   发布时间: 2011-02-20

另外code=Pytho里少了个n。

作者: iambic   发布时间: 2011-02-20