2.9 身份证号获取

# 获取随机个人信息写入表格

import sys,os
# base_dir=os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

# print(base_dir)
sys.path.append('./办公自动化/生成随机个人信息/')

# print(sys.path)

from openpyxl import Workbook
from 生成随机个人信息.Personal_Information import *
from datetime import datetime

# 创建一个Workbook对象
workbook = Workbook()

# 创建第一个sheet
# sheet = workbook.create_sheet('个人信息')
sheet = workbook.active

sheet.append(['姓名', '性别', '身份证号', '手机号', '邮箱', '银行卡号', '生日'])

for i in range(10):
    x = get_name()
    print("姓名:", x)
    s = get_sex()
    print("性别:", s)
    y = get_idnum()
    print("身份证号:", y)
    p = get_tel()
    print("手机号:", p)
    z = get_email()
    print("邮箱:", z)
    w = get_card_id()
    print("银行卡号:", w)
    b = datetime.strptime(y[6:14], "%Y%m%d").date()
    print("生日:", b)

    sheet.append([x, s, y, p, z, w, b])

workbook.save('./办公自动化/files/people_info.xlsx')