# 1. 类名.方法
# 2. def.方法(self)
# self.方法
import os, csv, shutil
import datetime
class Project:
def __init__(self):
self.key = 1
def create(self):
DataFile =input('请输入要创建的日期:')
N = int(input("请选择要减去的值:M-1/T-1"))
OP = str('-')
if OP == "-":
ResultTMP=int(DataFile)-int(N)
print(ResultTMP)
Result=str(ResultTMP)
fi = os.makedirs(Result)
file1 = Result + '.txt'
create_txt = open(file1, 'w')
create_txt.close()
shutil.move(file1, Result)
file2 = os.path.join(Result, Result)
f2 = os.makedirs(file2, exist_ok=True)
else:
print("Error")
if not (os.path.exists(file2)):
pass
print('该目录已存在')
else:
file3=Result + '.txt'
create_txt = open(file3, 'w')
create_txt.close()
shutil.move(file3,file2)
def again(self):
a = input('是否继续计算?继续请输入y,输入其他键将结束程序。')
if a != 'y':
self.key = 0
def main(self):
print('欢迎使用创建文件夹小程序!')
while self.key == 1:
self.create()
self.again()
print('感谢使用创建文件夹小程序!')
project1 = Project()
project1.main()