Last active
May 13, 2017 14:52
-
-
Save mattiemonster/f6bb13009151ac985e33ce5201a21cde to your computer and use it in GitHub Desktop.
A python file that echos a message and logs it.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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