python中readline()怎么用,还有readline和readlines,read的区别和用法a=['dewe','dsefwe','seww']>>> print(a.readline())Traceback (most recent call last):File "",line 1,in print(a.readline())AttributeError:'list' object has no attribute 'r
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/27 18:30:12
python中readline()怎么用,还有readline和readlines,read的区别和用法a=['dewe','dsefwe','seww']>>> print(a.readline())Traceback (most recent call last):File "",line 1,in print(a.readline())AttributeError:'list' object has no attribute 'r
python中readline()怎么用,还有readline和readlines,read的区别和用法
a=['dewe','dsefwe','seww']
>>> print(a.readline())
Traceback (most recent call last):
File "",line 1,in
print(a.readline())
AttributeError:'list' object has no attribute 'readline'
我不清楚readline的用法,
麻烦讲细致一点
python中readline()怎么用,还有readline和readlines,read的区别和用法a=['dewe','dsefwe','seww']>>> print(a.readline())Traceback (most recent call last):File "",line 1,in print(a.readline())AttributeError:'list' object has no attribute 'r
python中readline()是用来读取文本文件中的一行.
readline和readlines,read都是用来读取文件内容,readline()每次读取一行,当前位置移到下一行;readlines()读取整个文件所有行,保存在一个列表(list)变量中,每行作为一个元素;read(size)从文件当前位置起读取size个字节(如果文件结束,就读取到文件结束为止),如果size是负值或省略,读取到文件结束为止,返回结果是一个字符串.
f=open("myfile")
while True:
line=f.readline()
if line:
print line,
else:
break
f=open("myfile")
lines=f.readline() #lines是一个列表变量
f=open("myfile")
lines=f.read() #lines是一个字符串变量