am尝试将文件从GCP blob下载到临时文件并读取该临时文件。 但是正在从此行获取(blob.download_to_filename(temp.name)) nonetype ,这表明该文件未下载到临时文件。下面是我的python代码。
storage_cli=google.cloud.storage.Client.from_service_account_json(service_account.json')
bucket_name='cbucket'
bucket = storage_cli.get_bucket(bucket_name)
des='c_job_list.txt'
blob= bucket.blob(des)
with _NamedTemporaryFile() as temp:
blob.download_to_filename(temp.name)
print("file downloaded from blob")
with open(temp.name,'r') as f:
data=f.read()
print("opened temp file")
for i in f:
_job_id, _report_type, _since, _until = i.strip().split('|')
print(_job_id, _report_type, _since, _until)
下面是代码错误
(<type 'exceptions.TypeError'>, TypeError('coercing to Unicode: need string
or buffer, NoneType found',),
有没有一种方法可以达到上述要求?请先谢谢。