我有一个 python 代码,它打印我想重命名以供以后使用的对象
import urllib.request as url
pagina = "https://s3-ifc-coordinador-preprod.s3.amazonaws.com/"
pw = url.urlopen(pagina)
datos = pw.readlines()
print(datos)
for i in datos:
datos2 = i.decode("utf-8").split("BAEN/")
for j in datos2:
if j.count(".xlsx") > 0:
referencia = j.split("<")
#new_referencia = referencia.replace('Ago2019', 'May2020')
#print(new_referencia[0])
print(referencia[0])
结果:
VE02_FIFC_LUZOSORNO_BAENAgo2019.xlsx
VE02_FIFC_NORVIND_BAENAgo2019.xlsx
VE02_FIFC_POZO_ALMONTE_SOLAR_1_BAENAgo2019.xlsx
VE02_FIFC_SAESA_BAENAgo2019.xlsx
VE02_FIFC_SAFIRA_ENERGIA_CHILE_BAENAgo2019.xlsx
VE02_FIFC_SAN_JUAN_LAP_BAENAgo2019.xlsx
VE02_FIFC_SGA_BAENAgo2019.xlsx
VE02_FIFC_TACORA_ENERGY_BAENAgo2019.xlsx
VE02_FIFC_TRANSELEC_BAENAgo2019.xlsx
VE03_FIFC_AES_GENER_BAENAgo2019.xlsx
VE03_FIFC_CALAMA_SOLAR_1_BAENAgo2019.xlsx
VE03_FIFC_ENGIE_BAENAgo2019.xlsx
我需要将“Ago2019”更改为“May2020”
明明用replace(),不行。有谁知道该怎么做?
我要求的结果
VE02_FIFC_LUZOSORNO_BAENMay2020.xlsx
VE02_FIFC_NORVIND_BAENMay2020.xlsx
VE02_FIFC_POZO_ALMONTE_SOLAR_1_BAENMay2020.xlsx
VE02_FIFC_SAESA_BAENMay2020.xlsx
VE02_FIFC_SAFIRA_ENERGIA_CHILE_BAENMay2020.xlsx
VE02_FIFC_SAN_JUAN_LAP_BAENMay2020.xlsx
VE02_FIFC_SGA_BAENMay2020.xlsx
VE02_FIFC_TACORA_ENERGY_BAENMay2020.xlsx
VE02_FIFC_TRANSELEC_BAENMay2020.xlsx
VE03_FIFC_AES_GENER_BAENMay2020.xlsx
VE03_FIFC_CALAMA_SOLAR_1_BAENMay2020.xlsx
VE03_FIFC_ENGIE_BAENMay2020.xlsx
慕侠2389804
拉丁的传说
相关分类