0

我在尝试通过 Google input_helper_v2.py提供的此脚本在 Google NLP API 中为命名实体识别构建数据集时遇到了困难

问题来自函数_DownloadGcsFile,因为它抛出了这个错误:

gsutil_cp_cmd = ' '.join(['gsutil', 'cp', gcs_file, local_filename])
TypeError: sequence item 2: expected str instance, bytes found

我试过 put b' '.join(['gsutil', 'cp', gcs_file, local_filename]),但它会产生类似的问题。

在搜索信息时,我注意到可能是在 python 2.7 中开发的脚本导致了这种情况。

我会很感激任何帮助,因为我是一个完整的初学者。太感谢了。

4

1 回答 1

1

这意味着 gcs_file 的类型为bytes。因此,您需要将其设为字符串 ( str ) 类型。例如:

gsutil_cp_cmd = ' '.join(['gsutil', 'cp', gcs_file.decode('utf-8'), local_filename])
于 2020-09-16T23:04:26.083 回答