eri*_*rik 0 python amazon-s3 python-2.7
以下代码抛出了一个ValueError:解压缩的值太多了
if remote_folder is not None:
for directory_name, files in os.walk(file_path):
for filename in files:
remote_folder.key = os.path.join(
remote_file_path,
directory_name,
filename)
file_size_uploaded = remote_folder.set_contents_from_filename( # noqa
os.path.join(directory_name, filename), replace=True)
return False if file_size_uploaded == 0 else True
Run Code Online (Sandbox Code Playgroud)
此方法尝试将文件上载到S3 Bucket
任何人都可以解释为什么以及如何避免?
这个:
for directory_name, files in os.walk(file_path):
Run Code Online (Sandbox Code Playgroud)
os.walk返回3元组,因此当尝试将3元组分配给2元组时,您的异常会增加.
使用:
for root, dirs, files in os.walk(file_path):
Run Code Online (Sandbox Code Playgroud)
docs上的文档os.walk:https://docs.python.org/2/library/os.html#os.walk