python怎么另起一行
导读:python怎么另起一行?#readdatafromfilewithopen("data_src.txt",'rt' assrc:data=[ln.strip( forlninsrc]#distinctdataandwritetofilew...
python怎么另起一行?
#readdatafromfile
withopen("data_src.txt",'rt')assrc:
data=[ln.strip()forlninsrc]
#distinctdataandwritetofilewith','join
withopen("data_sto.txt",'wt')assto:
sto.write(','.join(list(set(data))))
python中set是“unorderedcollectionofuniqueelements”可以自动实现剔除重复数据。
声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!
若转载请注明出处: python怎么另起一行
本文地址: https://pptw.com/jishu/64303.html