当我打开电脑时,我不想一个接一个地打开所有的程序和文件来编辑我的网站,我想执行一个python脚本来为我打开它们。但是,当我运行它时,它总是打开一个索引.html文件位于名为“index”的文件夹中。我想让它打开说,网页.html在“webpages”文件夹中。你知道吗
#!/usr/bin/env python
import os, webbrowser, subprocess
os.chdir('C:/Users/Bruin/Desktop/My_Webpage')
current_path = os.getcwd()
file_to_open = input('What filename to open?')
print("hello")
#subprocess.call([r'C:\Users\Bruin\AppData\Local\atom\atom.exe', r'C:\Users\Bruin\Desktop\My_Webpage\'' + file_to_open + r'\'' + file_to_open + r'.html'])
subprocess.call([r'C:\Users\Bruin\AppData\Local\atom\atom.exe', r'C:\Users\Bruin\Desktop\My_Webpage\webpages\webpage.html'])
webbrowser.open('file:///C:/Users/Bruin/Desktop/My_Webpage/index/index.html', new=2)
我注释了我使用inputed变量的地方,因为即使显式地在脚本中输入我想直接打开的内容,它也不起作用。它在浏览器中打开很好。你知道吗
我也在PyCharm工作,不知道这是否重要。它在空闲时也不起作用。我不知道该去哪里。你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐