Zzsf11
Zzsf11
采纳率100%
2020-03-22 15:32

python文件打开报错TypeError: an integer is required (got type str)求解

已采纳

打开代码如下:

f=open("123.txt","rt","encode=utf-8")
 for i in f:
    i=i.split(",")
    print(i)

报错如下:

=RESTART: C:\Users\Zz\AppData\Local\Programs\Python\Python38-32\program\practise11.py
Traceback (most recent call last):
    File "C:\Users\Zz\AppData\Local\Programs\Python\Python38-32\program\practise11.py", line 1, in <module>
    f=open("123.txt","rt","encode=utf-8")
TypeError: an integer is required (got type str)

``

这是我想打开输出的文件

另外,为什么我的文件里有逗号的话,open就需要写“encode=utf-8”?

求大神解答
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

相关推荐