文章

Python3 从入门到实践 第十章 文件和异常 习题10-3-5

#coding:gbk
#filename = 'text.txt'
#warting = 'please set u login_name : '
#with open(filename,'a') as file_object:
#	file_object.write(input(warting))


#filename = 'guest_book.txt'
#warting = 'please set u login_name : '
#while True:
#	i = input(warting)
#	print('nice to mee you! '+i)
#	with open(filename,'a') as file_object:
#		file_object.write(i+'\n')

filename = 'love_python_why.txt'
warting = 'why u love python? '
warting += '\ntell me why: '

while True:
	i = input(warting)
	print('Think you for your pool .')
	with open(filename,'a') as file_object:
		file_object.write(i+'\n')#强调,换行符需要加到write里面,而不是用户的input
原文来自:Python3 从入门到实践 第十章 文件和异常 习题10-3-5,尊重自己,尊重每一个人;转发请注明来源!
0 0

发表评论