#10-2 message = 'Hello, my friend' print(message) message.replace('friend', 'partner') print(message) #10-3 filename = 'guest.txt' with open(filename, 'a') as f_ob: i = input('Enter your name:') f_ob.write(i) #10-4 filename = 'guesst_book.txt' with open(filename, 'a') as f: t = input('Enter your name: (input "exit" to exit)') while(t != 'exit'): print('Welcome! ' + t) f.write(t + '\n') t = input('Enter your name:') #10-5 filename = 'reason.txt' with open(filename, 'a') as f: t = input('Why do you like programming? (input "exit" to exit)') while(t != 'exit'): print('We got it.') f.write(t + '\n') t = input('Why do you like programming? (input "exit" to exit)')
py第十章习题
猜你喜欢
转载自blog.csdn.net/qq_38213586/article/details/80091572
今日推荐
周排行