aifc module Error: Python won't open file

蹲街弑〆低调 提交于 2019-12-25 06:18:18

问题


I'm just getting started with python so please bear with me ;)

While following a basic tutorial I ran into a problem while opening a file, here's the traceback:

File "/home/nick/Dropbox/workspace/pytest/schlange.py", line 55, in <module>
        f=open("file.csv","r")   
File "/usr/lib/python2.6/aifc.py", line 922, in open
        return Aifc_read(f)   
File "/usr/lib/python2.6/aifc.py", line 335, in __init__
        self.initfp(f)   
File "/usr/lib/python2.6/aifc.py", line 288, in initfp
        raise Error, 'file does not start with FORM id' 
aifc.Error: file does not start with FORM id

Does that mean that 'aifc.py' in my python installation is broken or did I miss something important here?


回答1:


You've decided to import * from aifc, and its open() has shadowed the built-in open(). This is why we don't import *. Import the module itself instead and use the reference to get to its names when required, e.g. aifc.open().



来源:https://stackoverflow.com/questions/14277629/aifc-module-error-python-wont-open-file

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