Created
January 27, 2020 12:51
-
-
Save seunggabi/e841f4759e7c3ce0ba3f713571d5e01d to your computer and use it in GitHub Desktop.
io.py
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 | |
import os | |
class IO: | |
def __init__(self, path, name): | |
if not os.path.exists(path): | |
os.makedirs(path) | |
self.path = path | |
self.name = name | |
def write(self, contents, hasTimestamp=True): | |
timestamp = time.strftime("%Y-%m-%d(%H:%M:%S)") | |
name = self.name | |
if hasTimestamp: | |
name += "_"+timestamp | |
file = open(self.path+"/"+name, "wb") | |
file.write(contents.encode('utf-8')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment