Fork me on GitHub

自己写的,产品中验证ok的代码,直接上实例:

import time

def file_create_func():
    loca = time.strftime('%Y-%m-%d-%H-%M-%S')
    new_name = str(loca)+".txt"
    print(loca)
    print(new_name)
    f = open(new_name,mode='w')
    f.write(loca)


if __name__=="__main__":
    file_create_func()

 

posted on 2023-01-31 12:00  虚生  阅读(86)  评论(0)    收藏  举报