Created
August 16, 2020 11:40
-
-
Save hvnsweeting/2ec928be5eed93cbf074ade711886807 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vcard_fmt = """BEGIN:VCARD | |
VERSION:2.1 | |
N:;{name} reg {course};;; | |
FN:{name} reg {course} | |
TEL;CELL:{telephone} | |
EMAIL: {email} | |
END:VCARD | |
""" | |
def make_vcard(course, name, telephone, email): | |
return vcard_fmt.format(name=name, course=course, telephone=telephone, email=email) | |
course = 'HCM2008' | |
students = [ | |
{'name': 'gà', 'telephone': '0999999999', 'email': 'ga@gmail.com', 'course': course}, | |
{'name': 'vịt', 'telephone': '0999999992', 'email': 'vit@gmail.com', 'course': course}, | |
] | |
vcards = [] | |
for student in students: | |
vcards.append(make_vcard(**student)) | |
print("\n".join(vcards)) | |
with open(f"{course}_students.vcf", "wt") as f: | |
f.write("\n".join(vcards)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment