开发者社区> 问答> 正文

python通过with open读取文件报错是什么原因

代码如下


with open("/Users/jiangyd/Downloads/arm/arm.txt","f") as f:
    for line in f:
        print(line)

运行报错:

Traceback (most recent call last):
  File "/Users/jiangyd/PycharmProjects/untitled16/b.py", line 33, in <module>
    with open("/Users/jiangyd/Downloads/arm/arm.txt","f") as f:
ValueError: invalid mode: 'f'

展开
收起
道月芬1 2021-10-20 21:19:32 687 0
0 条回答
写回答
取消 提交回答
问答排行榜
最热
最新

相关电子书

更多
From Python Scikit-Learn to Sc 立即下载
Data Pre-Processing in Python: 立即下载
双剑合璧-Python和大数据计算平台的结合 立即下载