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
不知道爲什麼會多出一個空行。。。