Python generates VCF address book files

Source: Internet
Author: User
Tags vcard

don't talk much.
First look at the VCF format:

Begin:vcard
version:2.1
fn:7814260568 
TEL; cell:0017814260568
End:vcard

(Note VCF files do not double-click to open, to be opened by text or by means of tools.
Or you can't shut it down. )

7814260568 means that the name
0017814260568 means the mobile number
001, 00 (+), 1 means the country code
such as 008613055534469 can be understood as +8613055534469
86 says China

to generate the code for the VCF format Address Book:

With open ("111.txt") as F:
    res = F.readlines ()

with open ("NEW.VCF", "w") as V: for
    R in res:
        NN = r.spli T (",")
        print (nn[0])
        print (nn[1])
        v.write ("begin:vcard" + "\ n")
        v.write ("version:2.1" + "\ n")
        v.write ("FN:" +nn[0]+ "\ n")
        v.write ("TEL; cell:00 "+nn[1]"
        v.write ("end:vcard" + "\ n")

111.txt content is:


The first half of each line is named, and the latter part is the state code number.
It was created in the United States, the U.S. Code is 001 (+1)
There are 1 of them in front of the phone number, like 12012792555.

Build Results:

Presumably this is the way you can customize your own;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.