源码

首页 » 归档 » 源码 » Python:AttributeError:’_ io.TextIOWrapper’对象…

Python:AttributeError:’_ io.TextIOWrapper’对象…


我有一个文本文件,我们称之为goodlines.txt,我想加载它并创建一个包含文本文件中每一行的列表.

我尝试使用split()过程,如下所示:

>>> f = open('goodlines.txt')
>>> mylist = f.splitlines()
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: '_io.TextIOWrapper' object has no attribute 'splitlines'
>>> mylist = f.split()
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: '_io.TextIOWrapper' object has no attribute 'split'

为什么我会收到这些错误?这不是我如何使用split()? (我使用的是python 3.3.2)

(0)

本文由 投稿者 创作,文章地址:https://blog.isoyu.com/archives/pythonattributeerror_-io-textiowrapperduixiang.html
采用知识共享署名4.0 国际许可协议进行许可。除注明转载/出处外,均为本站原创或翻译,转载前请务必署名。最后编辑时间为:9 月 20, 2019 at 02:00 下午

热评文章