31 lines
1.1 KiB
Python
31 lines
1.1 KiB
Python
|
import csv
|
||
|
def get_weixin_cuominzi(cuominzi):
|
||
|
with open('D:/2021/新媒体/微信错敏字.csv','w', newline='',encoding='utf-8') as csvfile:
|
||
|
writer = csv.writer(csvfile)
|
||
|
writer.writerow(
|
||
|
[ "错敏字","标题","日期", "链接", "公众号","位置"])
|
||
|
|
||
|
with open('D:/2021/新媒体/WX_LX.csv',encoding='utf8') as csvfile:
|
||
|
reader_wx = csv.reader(csvfile)
|
||
|
for r_w in reader_wx:
|
||
|
for c in cuominzi:
|
||
|
if str(c[0]) in str(r_w[4]) and str(c[1]) not in str(r_w[4]):
|
||
|
print(str(r_w[4]).index(str(c[0])))
|
||
|
writer.writerow([c[0], r_w[3], r_w[2], r_w[1], r_w[0],
|
||
|
str(r_w[4])[str(r_w[4]).index(str(c[0])) - 10:str(r_w[4]).index(str(c[0])) + 10]])
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
if __name__ == '__main__':
|
||
|
cuominzi = []
|
||
|
with open('D:/2021/新媒体/错敏字.csv') as csvfile:
|
||
|
reader = csv.reader(csvfile)
|
||
|
|
||
|
for r in reader:
|
||
|
if r[0] != '错敏字' and r[0] != '':
|
||
|
cuominzi.append(r)
|
||
|
print(cuominzi)
|
||
|
get_weixin_cuominzi(cuominzi)
|