Write a program to enter a list , The elements in the list are ID cards (18 position ), Get birthday information according to your ID number , State the ID card 7 To 10 Indicates the year of birth ,11 To 12 Indicates the month of birth ,13 To 14 Indicates the date of birth .
Input :
id_cards = ['310101199005052115', '320507199812280150']
Output :
310101199005052115:1990/05/05 320507199812280150:1998/12/28
#!/usr/bin/python
# -*- coding: UTF-8 -*-
"""
@author: Roc-xb
"""
def get_birthday(id_card):
year = id_card[6:10]
month = id_card[10:12]
day = id_card[12:14]
print("{}:{}/{}/{}".format(id_card, year, month, day))
if __name__ == '__main__':
id_cards = ['310101199005052115', '320507199812280150']
for id_card in id_cards:
get_birthday(id_card)