养猫的程序猿 2021-11-03 09:23 采纳率: 0%
浏览 15

TypeError:‘encording’ is an invalid keyboard argument for this function

原来程序是这样,我想打开num.txt这个文本,并且改名为file1.txt,但是一直报错
TypeError:‘encording’ is an invalid keyboard argument for this function

with  open(‘num.txt’,‘r’,encording=‘utf-8’) as file1:
contents = file1.read()
print(contents)

查找一些资料,改了后

import io
with  io.open(‘num.txt’,‘r’,encording=‘utf-8’) as file1:
contents = file1.read()
print(contents)

改完还是报错,求解

  • 写回答

1条回答 默认 最新

  • 於黾 2021-11-03 09:30
    关注

    encoding,你打错字了
    而且文件改名要用os.rename,你打开文件干什么

    评论

报告相同问题?

问题事件

  • 创建了问题 11月3日