O'Reilly logo
  • Longxiang Lyu thinks this is interesting:

10-4. Guest Book:

From

Cover of Python Crash Course

Note

import datetime
filename = 'guest_book.txt'

with open(filename, 'a') as file_object:
while True:
flag = raw_input('\nenter Y/y if you want to proceed to enter usernames: ')
if flag != 'Y' and flag != 'y':
break
name = raw_input('name: ')
now = datetime.datetime.now()
print("Hello, " + name)
file_object.write(str(now) + " " + name + " visited\n")