Skip to content

Instantly share code, notes, and snippets.

@mattiemonster
Last active May 13, 2017 14:52
Show Gist options
  • Save mattiemonster/f6bb13009151ac985e33ce5201a21cde to your computer and use it in GitHub Desktop.
Save mattiemonster/f6bb13009151ac985e33ce5201a21cde to your computer and use it in GitHub Desktop.
A python file that echos a message and logs it.
import time
current_time = time.localtime()
newline = "\n"
title = "log_" + time.strftime("%d-%m-%Y %H-%M-%S", current_time) + ".txt"
file = open(title, "w+")
current_time = time.localtime()
file.writelines(time.strftime('%d-%m-%Y %H:%M:%S', current_time))
file.writelines(" - Initialised.")
file.writelines(newline)
print("Hello! Welcome to the echo app. You type something in and it will repeat it!")
current_time = time.localtime()
file.writelines(time.strftime('%d-%m-%Y %H:%M:%S', current_time))
file.writelines(" - Asking for input.")
file.writelines(newline)
message = str(input("Please enter something for me to repeat: "))
current_time = time.localtime()
file.writelines(time.strftime('%d-%m-%Y %H:%M:%S', current_time))
file.writelines(" - Got input. Input: " + message + ". Repeating...")
file.writelines(newline)
print(message)
current_time = time.localtime()
file.writelines(time.strftime('%d-%m-%Y %H:%M:%S', current_time))
file.writelines(" - Repeated! Now exiting...")
file.writelines(newline)
print("Done! Now exiting...")
exit(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment