def save2(c=0): try: global cfile filename = cfile fi = open(filename, "w") fi.write(txt.get("1.0", END)) fi.close() except: print("error bad file")
def esave2(c=0): try: global cfile filename=fi.asksaveasfilename(title = "Select file to save",filetypes = (("python 3.5 files","*.py"),("all files","*.*"))) fi=open(filename,"w") fi.write(ccdoe.encypt(e,txt.get("1.0",END))) fi.close() except: print("error bad file")
def run(x=0, d=2): global cfile fi = open("runaction.py", "w") fi.write(txt.get("1.0", END)) fi.close() r = open("runaction.py", "r") exec(r.read()) txt2.insert(END, "run:" + t.asctime() + cfile) r.close()
def run(): fi = open("runaction.py", "w") fi.write(txt.get("1.0", END)) fi.close() r = open("runaction.py", "r") exec(r.read()) txt2.insert(END, "run:" + t.asctime() + r.name) r.close()
def upload(destpath, srcpath): if not os.path.exists(srcpath): print("ERROR: No this file!\n") message = messagebox.showwarning(title="warning", message="ERROR: No this file!") pass sfp = open(srcpath, "r", encoding="utf-8") contents = sfp.read() sfp.close() createfile(destpath) fd = open(destpath, mode="w", encoding="utf-8") fd.write(contents) fd.close()
def download_url(url, save_path, chunk_size=1024): r = requests.get(url, stream=True) with open(save_path, 'wb') as fd: for chunk in r.iter_content(chunk_size=chunk_size): fd.write(chunk)