合规国际互联网加速 OSASE为企业客户提供高速稳定SD-WAN国际加速解决方案。 广告
``` def save_csv(m,n): CSV = open(m,"w") t = "" for i in range(len(n)): t += str(n[i]) + "列表分隔处" t = t.replace(",","此处为原来的逗号") x = list(filter(None,t.split("列表分隔处"))) CSV.write(",".join(x)) CSV.close() def open_csv(m): file = open(m,"r").read() file = file.replace(",","从此处分割") file = file.replace("此处为原来的逗号",",") new_list = file.split("从此处分割") print("解析出的列表为{}".format(new_list)) def main(): n = input("请输入列表元素,以分好分割:") m = input("请输入要保存的csv文件名:") n = n.split(";") print("输入的列表为{}".format(n)) save_csv(m,n) open_csv(m) main() ``` ``` file = open("777.csv","r").read() file = file.replace(",","从此处分割") print(file) file = file.replace("此处为原来的逗号",",") print(file) new_list = file.split("从此处分割") print(new_list) print(type("解析出的列表为{}".format(new_list))) ```