如果这个问题以前在其他地方被问过或回答过,我很抱歉。我找不到它。
我对python还比较陌生,目前我正在设置一个脚本,以便通过哨兵卫星模块从ESA哨兵中心下载文件。
现在它正在工作,但我希望它有一种方法来打印所涉及的总文件大小。我已经让它打印所有文件的名称和它们各自的数据大小。我还列出了文件总数。现在,我只需要将单个数据大小求和为1。
下面是我的代码片段:
print("Listing file name and size:")
print("")
for n in range(0, np.size(bu_images_json["features"])):
print("Image name: ",json.dumps(bu_images_json["features"][n]["properties"]["title"]))
print("File size: ",json.dumps(bu_images_json["features"][n]["properties"]["size"]))
print("Found", n+1, "files availible for download")
print("Total amount to download")
看起来就像这样
Image name: "S2A_OPER_PRD_MSIL1C_PDMC_20161009T061329_R010_V20160727T140022_20160727T140246"
File size: "5.02 GB"
Image name: "S2A_OPER_PRD_MSIL1C_PDMC_20161009T060351_R139_V20160726T142942_20160726T143122"
File size: "5.99 GB"
Image name: "S2A_OPER_PRD_MSIL1C_PDMC_20160720T213054_R053_V20160720T141008_20160720T141008"
File size: "5.65 GB"
Found 131 files availible for download
Total amount to download
如果有人知道任何github页面或类似的东西,任何人都曾在其中玩过并扩展了sentinelsat模块--那么我也希望有一个链接。
谢谢您抽时间见我。
发布于 2018-08-13 15:54:47
from re import sub
print("Listing file name and size:")
total = 0
print("")
for n in range(0, np.size(bu_images_json["features"])):
print("Image name: ",json.dumps(bu_images_json["features"][n]["properties"]["title"]))
print("File size: ",json.dumps(bu_images_json["features"][n]["properties"]["size"]))
total += float(sub('[^0-9.]','',json.dumps(bu_images_json["features"][n]["properties"]["size"])))
print("Found", n+1, "files availible for download")
print("Total amount to download: ",total)https://stackoverflow.com/questions/51825694
复制相似问题