Skip to content

Instantly share code, notes, and snippets.

@hvnsweeting
Created August 16, 2020 11:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hvnsweeting/2ec928be5eed93cbf074ade711886807 to your computer and use it in GitHub Desktop.
Save hvnsweeting/2ec928be5eed93cbf074ade711886807 to your computer and use it in GitHub Desktop.
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