【发布时间】:2022-02-21 07:58:27
【问题描述】:
尝试对来自 2 个内容非常相似的不同 txt 文件的集合求和。
内容示例:
https://articulo.mercadolibre.com.ar/MLA-1113638999-placa-de-video-colorful-gt710-nf-1gb-ddr3-garantia-oficial-_JM;Placa De Video Colorful Gt710 Nf 1gb Ddr3 Garantia Oficial;gold_special;True;6999
https://articulo.mercadolibre.com.ar/MLA-795327882-placa-de-video-geforce-gt-710-1gb-ddr3-pc-gamer-gt710-dx12-_JM;Placa De Video Geforce Gt 710 1gb Ddr3 Pc Gamer Gt710 Dx12;gold_special;True;7499
我正在尝试使用以下代码(原始代码的简化):
with open("gt-710.txt","r") as f:
a = f.readlines()
with open("gt-7102.txt","r") as f:
b = f.readlines()
c = set(a).update(set(b))
print(c)
我不断得到的输出是 NONE,我尝试在不更新的情况下打印每组,并且它们做得很好,但是一旦我尝试总结它们,它们就会返回 NONE。
【问题讨论】:
-
我相信这是一个重复的问题:stackoverflow.com/questions/18038003/…