文章目录
1. Python代码
file = open('test.vcf', 'r', encoding='utf-8')
tels = []
for line in file:
line = line.strip('\n')
contents = line.split(':')
if contents[0] == 'TEL;TYPE=CELL':
print(contents[1])
tels.append(contents[1])
file.close()
# tels.append('13694091773')
# tels.append('13694091773')
tels = set(tels) # 去重
for t in tels:
print(t)
print(len(tels))
2. test.vcf文件内容
BEGIN:VCARD
VERSION:3.0
N;CHARSET=gb2312:13694091773
FN;CHARSET=gb2312:13694091773
TEL;TYPE=CELL:13694091773
END:VCARD
BEGIN:VCARD
VERSION:3.0
N;CHARSET=gb2312:15875485389
FN;CHARSET=gb2312:15875485389
TEL;TYPE=CELL:1