Every line of 'python save file' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.
39 def save_file(self, data, path): 40 """Stores string data to a file at given path""" 41 filepath = os.path.join(self.base_path, path) 42 43 with open(filepath, "w+") as file: 44 data = file.write(str(data)) 45 return data
3 def save(file_, *args, **kwargs): 4 """ 5 Save the value of some data in a file. 6 Usage: save('misdatos.pypic','a',b=b) 7 8 """ 9 f=open(file_, "wb") 10 dict = kwargs 11 for name in args: 12 dict[name] = eval(name) 13 pickle.dump(dict, f, protocol=2) 14 f.close
81 def _save_as_module(file, data): 82 if not data: 83 return 84 with open(file, 'w') as f: 85 f.write('DATA=') 86 f.write(str(data)) 87 f.flush()
144 def save_file(): 145 type_list = [("Text files", "*.txt")] 146 file_name = tkFileDialog.asksaveasfilename(filetypes=type_list, 147 defaultextension=".txt") 148 print file_name 149 if file_name != "": # save file if user entered a file name 150 output_file = open(file_name, "w") 151 output_file.writelines(result_poem.cget("text")) 152 output_file.close()
30 def save_file(): 31 file_path = filedialog.asksaveasfilename() 32 33 try: 34 filename = file_path.split("/")[-1] 35 text_widget = root.nametowidget(notebook.select()) 36 content = text_widget.get("1.0", "end-1c") 37 38 with open(file_path, "w") as file: 39 file.write(content) 40 41 except (AttributeError, FileNotFoundError): 42 print("Save operation cancelled") 43 return 44 45 notebook.tab("current", text=filename)
221 def saveFile(self, content, mode='w'): 222 """ 223 Save exported items to a file 224 """ 225 226 # Save to file 227 try: 228 file = open(self.path, mode) 229 file.write(content) 230 file.close() 231 232 print("The vault has been exported to the file `%s`." % (self.path)) 233 except Exception as e: 234 print("The vault could not be exported to the file `%s`." % 235 (self.path)) 236 print(e)
31 def save_text(data, filename): 32 with open(filename, 'w') as f: 33 f.write(data)
44 def pickle_save(file_name, data): 45 with open(file_name, 'wb') as f: 46 pickle.dump(data, f, protocol=pickle.HIGHEST_PROTOCOL)
43 def PickleSave(file_name, data): 44 with open(file_name, "wb") as f: 45 pickle.dump(data, f, protocol=pickle.HIGHEST_PROTOCOL)