Skip to content

Instantly share code, notes, and snippets.

@seunggabi
Created January 27, 2020 12:51
Show Gist options
  • Save seunggabi/e841f4759e7c3ce0ba3f713571d5e01d to your computer and use it in GitHub Desktop.
Save seunggabi/e841f4759e7c3ce0ba3f713571d5e01d to your computer and use it in GitHub Desktop.
io.py
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