If you want to choose where the file will be saved you can use the asksaveasfile
method of the tkFileDielog
module, just import the required libraries of TKinter
.
Here is an example for you:
import Tkinter, tkFileDialog
def salvaarquivo(texto):
f = tkFileDialog.asksaveasfile(mode="w", )#A foi opcao definida para escrita.
if f is None:
return
f.write(texto)
f.close()
salvaarquivo(raw_input("Digite um texto para ser salvo:"))
Documentation for tkFileDialog .
Font .
Note: If you do not have TKinter
installed on your machine, you can download it and install it following the instructions of the TKinter
site.