小编use*_*493的帖子

告诉Python将.txt文件保存到Windows和Mac上的某个目录

你如何告诉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)

python

42
推荐指数
5
解决办法
25万
查看次数

在Python中以Web浏览器以编程方式打开URL

我有一个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)

python url tkinter hyperlink

7
推荐指数
1
解决办法
2156
查看次数

标签 统计

python ×2

hyperlink ×1

tkinter ×1

url ×1