個人プログラム

個人メモ
ふと思ったことをテキストに書き出すプログラム

なお、batでループさせる。

import shutil
import datetime
import os


path = "tell.txt"
f = open(path,mode="a")
path2 = "tell_old.txt"
f2 = open(path2,mode="a")
print("pass or "" or list or old")
val = input("input : ")
today = datetime.datetime.now()
today = today.strftime('%H:%M')
if val == "pass" or val == "":
 pass
elif val == "clear":
 today = datetime.date.today()
 today = today.strftime('%Y%m%d')
 #message  = "tell" + str(today) + ".txt"
 #print (os.path.exists(message))
 #shutil .copyfile(path,message)
 f = open(path,'r')
 f2.write(f.read())
 f = open(path,'w')
 message = "\n"+"Content : " + str(today)
 f.write(message)
 f.close()
elif val == "list":
 path2 = "tell_old.txt"
 f2 = open(path2,mode="r")
 lines = f2.readlines()
 print(len(lines))
elif val == "old":
 path3 = "tell_old.txt"
 f3 = open(path3,mode="r")
 print(f3.read())
else:
 #print ("input sumally")
 #val2  = input("input : ")
 message = "\n" + str(today) + "," + str(val) #+ "," + str(val2)
 print("")
 f.write(message)
f = open(path)
print("")
print(f.read())
print("")
f.close()

この記事が気に入ったらサポートをしてみませんか?