【发布时间】:2023-04-03 20:40:01
【问题描述】:
我正在尝试使用文件中的数据集在 ML 中实现我的项目
authors_file_handler = open(authors_file, "r")
authors = pickle.load(authors_file_handler)
authors_file_handler.close()
在这之后我在这行得到错误
作者 = pickle.load(authors_file_handler)
TypeError: a bytes-like object is required, not 'str'
【问题讨论】:
-
您在哪一行得到错误?请提供完整的追溯。
-
试试:
authors = pickle.load(bytes(authors_file_handler,encoding="utf-8"))
标签: python string python-3.x byte file-handling