你如何告诉Python保存文本文件的位置?
例如,我的计算机正在运行桌面上的Python文件.我希望它将所有文本文件保存在我的文档文件夹中,而不是保存在桌面上.我如何在这样的脚本中执行此操作?
name_of_file = raw_input("What is the name of the file: ")
completeName = name_of_file + ".txt"
#Alter this line in any shape or form it is up to you.
file1 = open(completeName , "w")
toFile = raw_input("Write what you want into the field")
file1.write(toFile)
file1.close()
Run Code Online (Sandbox Code Playgroud) 我有一个tkinter脚本.我想知道无论如何都是这样,当你点击按钮它会带你到一个网站
from tkinter import *
app = Tk()
app.geometry("250x400")
app.title("Links")
def Link():
?
button1 = Button(app, text = "To a web site.", command = Link)
button1.pack()
app.mainloop()
Run Code Online (Sandbox Code Playgroud)