Python练习题 10-3~10-4 访客问题
2017-06-04 09:19
393 查看
10-3 访客:编写一个程序,提示用户输入其名字;用户作出响应后,将其名字写入到文件 guest.txt 中。10-4 访客名单:编写一个 while 循环,提示用户输入其名字。用户输入其名字后,在屏幕上打印一句问候语,并将一条访问记录添加到文件 guest_book.txt 中。确保这个文件中的每条记录都独占一行。
guest.py:
Hint="please enter your name :" control=1 while control: Name=input(Hint.title()) if Name=='#': break file.close() with open('guest.txt','a') as file: file.write(Name.title()+'\n')
guest.txt__first
guest.txt_last
Wei Lian Xin不知道为什么会多出一个空行。。。
相关文章推荐
- 10_python_练习题——兔子问题与斐波那契數列
- ValueError: invalid literal for int() with base 10 分类: 问题总结 python 2013-12-09 09:12 3782人阅读 评论(0) 收藏
- python学习——练习题(10)
- Python3读取深度学习CIFAR-10数据集出现的若干问题解决
- Python 100练习题[1-10]
- Python练习题 10-11~10-12喜欢的数字
- Python练习题 10-13 验证用户
- Python基础(3)——北京市地铁买票问题(思维练习题)
- Python练习题 10-1 Python 学习笔记
- Python练习题 10-6~10-7乘法练习题
- python读取dat文件时遇到16进制转化成10进制问题
- Python3 解决编码问题: `UnicodeEncodeError: 'gbk' codec can't encode character '\xa0' in position 10: ille
- 快乐Python快速上手系列10 - 中文编码问题
- Python练习题 9-7~9-8管理员问题
- Python练习题 10-2 C语言学习笔记
- python练习题 1-10
- Python3 解决编码问题: `UnicodeEncodeError: 'gbk' codec can't encode character '\xa0' in position 10: ille
- python 10-22遇到的问题
- python 回溯法 子集树模板 系列 —— 10、m着色问题
- Ubuntu 16.04 Python读取MySQL数据库中文乱码的问题