添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
locale.setlocale(locale.LC_CTYPE,'chinese') t1 = time.strftime("%Y-%m-%d",time.localtime()) t2 = time.strftime("%Y-%m-%d %H%M%S",time.localtime()) print(t1) print(t2) os.chdir("C:\\") os.mkdir(t1) os.chdir(t1) filename = t2+".txt" with open(filename,'w',encoding='utf-8') as file_object: file_object.write("Hello World!") print(os.path.abspath(filename)) with open(filename,'r',encoding='utf-8') as file_object1: print(file_object1.readlines())
import time
import os
dir_name = time.strftime("%Y%m%d")
dir_path = os.path.join("C:\\",dir_name)
print(dir_name)
print(dir_path)
os.mkdir(dir_path)
os.chdir(dir_path)
filename = time.strftime("%Y%m%d%H%M%S") +".txt"
with open(filename,'w',encoding='utf-8') as file_object:
    file_object.write(
import timeimport osimport localelocale.setlocale(locale.LC_CTYPE,'chinese')t1 = time.strftime("%Y-%m-%d",time.localtime())t2 = time.strftime("%Y-%m-%d %H%M%S",time.localtime())print(t1)print(t2)os.chdir("C:\\")os.mkdir(t1)os.chdir(t1)filename. now = datetime.now() # 获得 当前 时间 timestr = now.strftime("%Y_%m_%d_%H_%M_%S") print('年_月_日_时_分_秒:', timestr) dir = os.getcwd() + '/演示' + timestr # os.g var minute = now.getMinutes(); var second = now.getSeconds(); console.log(year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second); 这段代码会输出 当前 时间 年月日 时分秒 ,例如:2021-08-23 14:30:00。