简体   繁体   English

如何从另一个 python 文件中运行 python 文件

[英]How to run a python file from inside another python file

website\data网站\数据

I have these two folders, where data is inside the website folder.我有这两个文件夹,其中数据位于网站文件夹中。 In website, I have a file called main.py.在网站上,我有一个名为 main.py 的文件。 I would like this script to run the three other python scripts inside data.我希望这个脚本在数据中运行其他三个 python 脚本。 How would I do this?我该怎么做?

I also have a subfolder within data called reports in which there is a.xlsx excel file.我还有一个名为报告的数据子文件夹,其中有一个.xlsx excel 文件。 I would also like to launch this after running all three files inside data.我还想在数据中运行所有三个文件后启动它。 How would I do this?我该怎么做?

Question unclear, but you could import the content of those files into main.py then execute the content.问题不清楚,但您可以将这些文件的内容import main.py 然后执行内容。

Also, you want to "launch" your xlsx file?另外,您想“启动”您的 xlsx 文件吗? or just exec a software that could open it?或者只是执行一个可以打开它的软件?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM