Skip to content

Instantly share code, notes, and snippets.

@chouch0u
Created June 19, 2015 14:04
Show Gist options
  • Save chouch0u/e81ac83ac923351b84e8 to your computer and use it in GitHub Desktop.
Save chouch0u/e81ac83ac923351b84e8 to your computer and use it in GitHub Desktop.
import time
import os
import sys
file_path = "/Users/theme/Desktop/English vocabulary.txt"
def judge_file():
file_state = os.path.exists(file_path)
if file_state:
print "File was exist."
else:
f = open(file_path,'w')
f.close()
print "File was created."
def read_file_create_time():
file_info = os.stat(file_path)
file_create_time = time.strftime("%Y.%m.%d",time.gmtime(file_info.st_ctime))
today_time = time.strftime("%Y.%m.%d", time.gmtime())
if file_create_time == today_time:
return "True"
else:
f = open(file_path,'w')
f.close
read_file_create_time()
judge_file()
file_check = read_file_create_time()
if file_check == "True":
f = open(file_path,'a')
if len(sys.argv) == 3:
f.write(sys.argv[1] + ' ' + sys.argv[2] + '\n')
if len(sys.argv) == 4:
f.write(sys.argv[1] + ' ' + sys.argv[2] + ' ' + sys.argv[3] +'\n')
if len(sys.argv) == 5:
f.write(sys.argv[1] + ' ' + sys.argv[2] + ' ' + sys.argv[3] + ' ' + sys.argv[4] + '\n')
f.close()
print 'Success'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment