如何将其转换为 vcf 文件?BEGIN:VCARDVERSION:3.0FN:Nicolas RizzoMAIL;TYPE=home:nizzoeh@hotmail.comEND:VCARD我通过这样做生成了上面的VCard:j = vobject.vCard() o = j.add('fn') o.value = rowr.name o = j.add('mail') o.type_param = "email" o.value = rowr.email vcard = j.serialize()
1 回答
UYOU
TA贡献1878条经验 获得超4个赞
只需将其写入文本文件即可。
这是一个完整的示例:
import vobject
from types import SimpleNamespace # for testing
list_person = [SimpleNamespace(name="test1", email="test1@contoso.com"),SimpleNamespace(name="test2", email="test2@contoso.com")]
vcf_file_path = 'rep_tel.vcf'
with open(vcf_file_path , 'w',encoding='utf8') as file_vcard:
for rowr in list_person:
vcard = vobject.vCard()
o = vcard.add('fn')
o.value = rowr.name
o = vcard.add('email')
o.type_param = 'INTERNET'
o.value = rowr.email
file_vcard.write(vcard.serialize())
添加回答
举报
0/150
提交
取消