python - 为什么我无法访问 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()
'''** 你明白了吗?**
解决方案
除了f.read
. 遍历文件会遍历文件中的每一行。
推荐阅读
- python - 在python中,我怎样才能看到即将被垃圾收集的对象来自哪里?
- javascript - Javascript ES6 国际版。日期/时间格式
- html - 使列的高度调整为图像的响应高度(Flexbox)
- javascript - 如果javascript条件为真,如何调用php函数
- django - AbstractBaseUser 和 AbstractUser 之间的自定义用户模型有什么区别
- machine-learning - 不平衡数据的特征工程
- vba - 用于重置插入 Word 文档中的文本框的计数器的代码
- kubernetes - 具有惰性序列和 SSE 的有状态服务——如何通过容错进行分发?
- pine-script - 脚本实时冻结最新数据(重新绘制),仅在刷新浏览器页面时显示所需值
- javascript - jQuery pop 从末尾删除项目