I am using discord.py.
On my on_ready() function I want to open the open, read, and write on the pkl file.
but it keeps giving this error:
data = pickle.load(file)
_pickle.UnpicklingError: invalid load key, '\xef'.
This is the code I was using:
@bot.event
async def on_ready():
try:
with open("test.pkl", "rb") as file:
data = pickle.load(file)
print(data)
with open("test.pkl", 'wb') as file:
file.close()
with open("test.pkl", 'wb') as file:
pickle.dump({}, file)
except:
raise