1.读入文件并检查你的生日四位数字在不在文件中
file_name='data.txt'
birthday = input('请输入你的4位数生日:')
data_str = ''
with open(file_name) as data:
data_strs = data.readlines()
for data in data_strs:
data_str += data.strip()
# print(data_str)
if birthday in data_str:
print('你的生日在其中')
else:
print('你的生日不在其中!')
file_name = 'study.txt'
with open(file_name,'w') as file:
file.writelines("i love python 3000 times\n")
file.writelines("i love python 3000 times\n")
file.writelines("i love python 3000 times\n")