python造测试数据存到excel

代码:

复制代码
from ExcelHandler import ExcelHandler
from faker import Faker		# 导入faker库的Faker方法
# ↓默认为en_US,只有使用了相关语言才能生成相对应的随机数据
fk=Faker(locale="zh_CN")


def create_date():

    m =int(input('请输入要造的数据条数m的值:'))
    for i in range(1,m+1):
        """手机号"""
        fk.phone_number()
        ExcelHandler(file=r'C:\Users\dell\Desktop\test_data_01.xlsx').write(
            file=r'C:\Users\dell\Desktop\test_data_01.xlsx', row=i + 1,
            column=1, name='ceshi', data=fk.phone_number())

        """身份证号"""

        ExcelHandler(file=r'C:\Users\dell\Desktop\test_data_01.xlsx').write(
            file=r'C:\Users\dell\Desktop\test_data_01.xlsx', row=i + 1, column=2, name='ceshi', data=fk.ssn())


if __name__=="__main__":
    print(create_date())

结果:

相关推荐
unable code1 天前
磁盘取证-Flying_High
网络安全·ctf·misc·1024程序员节·磁盘取证
unable code2 天前
磁盘取证-ColorfulDisk
网络安全·ctf·misc·1024程序员节·内存取证
unable code3 天前
磁盘取证-[第十章][10.1.2 磁盘取证方法]磁盘取证1
网络安全·ctf·misc·1024程序员节·内存取证
开开心心就好4 天前
免费抽奖工具支持批量导入+自定义主题
linux·运维·服务器·macos·pdf·phpstorm·1024程序员节
开开心心就好9 天前
卸载工具清理残留,检测垃圾颜色标识状态
linux·运维·服务器·python·安全·tornado·1024程序员节
子燕若水10 天前
Facebook reels 运营指南
1024程序员节
尘觉13 天前
创作 1024 天|把热爱写成长期主义
数据库·1024程序员节
写点什么呢13 天前
Word使用记录
word·1024程序员节
开开心心就好14 天前
内存清理工具点击清理,自动间隔自启
linux·运维·服务器·安全·硬件架构·材料工程·1024程序员节
开开心心就好14 天前
内存清理工具开源免费,自动优化清理项
linux·运维·服务器·python·django·pdf·1024程序员节