首页 > 解决方案 > 为什么我无法访问 open() 的内容

问题描述

***价值是多少?价值是什么?价值是什么?价值是什么?价值是什么?


'''

myfile = open('mytext.text')
"""
 if I print myfile it will not print
 its content I need to use read.() 
 function to read its content

"""
for line in myfile:
    print(line)
"""
  Now my question is why when I use this
  code it prints each line?? I didn't use 
  read.() function, how it reach to the
  content?? Please help me and thanks.
"""
myfile.close()

'''** 你明白了吗?**

标签: pythonfile

解决方案


除了f.read. 遍历文件会遍历文件中的每一行。


推荐阅读