python写了三条print语句,为什么只执行一条
withopen('learning_python.txt')asfile_object:forlineinfile_object:print(line.strip())...
with open('learning_python.txt') as file_object:
for line in file_object:
print(line.strip())
contents=file_object.read()
print(contents)
lines=file_object.readlines()
for line in lines:
print(line.rstrip())
如上,想打印三次文档内容,但输出只打印一次。为什么呢? 展开
for line in file_object:
print(line.strip())
contents=file_object.read()
print(contents)
lines=file_object.readlines()
for line in lines:
print(line.rstrip())
如上,想打印三次文档内容,但输出只打印一次。为什么呢? 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询