我是Python的新手,并且在尝试读取.csv文件时遇到了可怕的时间。我使用的代码如下:在Python中读取文件错误
>>> dat = open('blue.csv','r')
>>> print dat()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'file' object is not callable
谁能帮我诊断此错误或借给如何读取该文件有什么建议?对不起,如果已经有这个问题的答案,但我似乎无法找到它。
您是否阅读过[文档](https://docs.python.org/2/library/csv.html)?有一堆例子。或者也许是[CSV模块上的Python MOTW](https://pymotw.com/2/csv/)?还有更多的例子。 – skrrgwasme
所以当我使用'print dat'时,我得到以下'>>> print dat <打开文件'trims.csv',模式'r'在0x6fffff496f0>'但我期待看到我的数据来自.csv – user6291
'print dat.readlines()'或'.read()'。 –