如何在 PyCharm 中修复 "File was loaded in the wrong encoding: UTF-8"?

How to fix "File was loaded in the wrong encoding: UTF-8" in PyCharm?

我正在尝试使用 pickle 将信息保存在文件中,但是当我打开文件时,信息不是以二进制格式存储的,我收到消息

"File was loaded in the wrong encoding: UTF-8"

import pickle

with open('text.pickle', 'wb') as file:
    pickle.dump('some text', file)

要打开 pickle 文件,在 Python 中您需要使用 pickle.load()

infile = open('text.pickle', 'rb')
new_dict = pickle.load(infile)
infile.close()

查看 this article 使用 pickle