zoukankan      html  css  js  c++  java
  • python 制作自动化脚本

    1、用faker库生成数据

    from faker import Faker
    import csv
    import datetime
    
    f=Faker(locale='zh_CN')
    
    #创建文件
    file=open("textdate.csv","w",newline="")#newline为空防止换行出现空行
    
    #获取写文件对象
    fwrite=csv.writer(file)
    
    for i in range(1,11):
        num=str(i).zfill(5)#zfill左填充的方法
        print(num)
        tname=f.name()
        #写入内容
        fwrite.writerow([num,tname])#[]将输出内容固定到一个单元格
    #关闭文件
    file.close()

    上述代码运行效果如下:
    
    

      

  • 相关阅读:
    非空约束
    leetcode208
    leetcode207
    leetcode395
    leetcode116
    leetcode105
    leetcode131
    leetcode73
    leetcode200
    leetcode17
  • 原文地址:https://www.cnblogs.com/sunfanvlog/p/13984801.html
Copyright © 2011-2022 走看看