利用python输出000至999中间的数

打造一个000-999的字典

for i in range(1000):
    if i<10:
        i = '00'+str(i)
    elif 10<=i and i<100:
        i ='0'+str(i)
    else:
        i=str(i)
    with open('1.txt', 'a') as f:
        f.write(i+"\n")

 

posted @ 2019-04-30 11:12  Bypass  阅读(3695)  评论(0编辑  收藏  举报