把excel中的手机号变成vcf

import xlrd
import re

def qu():
wb = xlrd.open_workbook('xxxxxxxx.xlsx')
sh = wb.sheet_by_name('9.10')
for i in range(sh.nrows)[1:200]:
i_li = sh.row_values(i)
print(i_li)
if i_li[-1]:
number_list = re.findall('\d+',str(i_li[-1]))
print(number_list)
for number in number_list:
if number !='0':
with open("通讯.vcf", "a", encoding='utf-8')as f:
f.write('BEGIN:VCARD')

f.write('\n')

f.write('VERSION:3.0')

# f.write('\n')
#
# f.write('N;CHARSET=utf-8:;{};;;'.format(i_li[0]))

f.write('\n')

# f.write('FN;CHARSET=utf-8: {}'.format(i_li[0]))
f.write('FN:{}'.format(i_li[0]))
f.write('\n')
f.write('TEL;type=CELL;type=VOICE;type=pref:{}'.format(int(float(number))))
# f.write('TEL;CELL:{}'.format(int(float(bunber))))

f.write('\n')

f.write('END:VCARD')

f.write('\n')


qu()
posted @ 2020-09-16 18:08  一颗吃不完的糖  阅读(676)  评论(0编辑  收藏  举报