0
点赞
收藏
分享

微信扫一扫

【Python】Python向txt文本中写入数据

古月无语 2022-01-06 阅读 80
python
file =open('D:\\wk\\data.txt','w')

for i in range(1,101):
    file.write(("123101196001015" +str(i).zfill(3) )+'\n')#身份证号
file.close()

注:str.zfill(width)指定字符串的长度,原字符串右对齐,前面填充0

举报

相关推荐

0 条评论