簡體   English   中英

TypeError:輸入()得到了一個意外的關鍵字參數“編碼”

[英]TypeError: input() got an unexpected keyword argument 'encoding'

我收到以下錯誤: TypeError: input() got an unexpected keyword argument 'encoding' when trying to read from stdin in python using fileinput.input() ,但文檔說文件輸入應該這樣使用。

我正在使用 python 3.9

import fileinput
for line in fileinput.input(encoding="utf-8"):
    process(line)

在 Python 3.9 中, fileinput.input()不采用encoding參數(參見此處)。 該論點是在 Python 3.10 中引入的:

在 3.10 版更改:添加了僅關鍵字參數編碼和錯誤。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM