为什么去不掉?这样写不行吗?
def file_write(date):
f = open('C:\\Users\\123.000\\Desktop\\python练习\\考勤\\考勤.txt','a')
f.write(date)
f.write('\n')
f.close()
def file_clear(date): #排除重复日期
list1 = []
f = open('C:\\Users\\123.000\\Desktop\\python练习\\考勤\\考勤.txt')
for i in f:
if i != '\n':
i.rstrip('\n')
list1.append(i)
print(list1)
if date in list1:
date = input('你输入的日期已存在请重新输入:')
f.close()
while 1:
date = input('请输入您的考勤【以x.x的形式输入】(请按下‘Q’键退出):')
if date == 'Q' or date == 'q':
break
else:
file_clear(date)
file_write(date)
怎么去不掉?
|