Python 報錯:ValueError: binary mode doesn't take an encoding argument
在運行文件操作相關功能時報錯:ValueError: binary mode doesn't take an encoding argument
上代碼:
>>> with open("course_info","rb+",encoding="utf-8")as f: #rb+操作時不支持指定encoding參數 Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: binary mode doesn't take an encoding argument
原因分析:rb+操作時不支持指定encoding參數
解決辦法: 去掉encoding,改成 with open('course_info','rb+') as f: