[英]How to run a remote Python program from Windows command prompt
I have an app on my website, and I run it with Python from the Windows Command Prompt. 我的网站上有一个应用程序,我从Windows命令提示符下运行Python。
When I try opening it like this, 当我尝试这样打开它时,
python http://www.erickwilts.nl/apps/app.py
it says: 它说:
python: can't open file 'http://www.erickwilts.nl/apps/app.py': [Errno 22] Invalid argument
Is there a way I can do this? 有没有办法可以做到这一点?
Since the resource is located on webserver, you must download it first. 由于资源位于Web服务器上,因此必须先将其下载。 You can do it with urllib2
你可以用urllib2
做到这一点
import urllib2
exec(urllib2.urlopen("http://www.erickwilts.nl/apps/app.py").read())
executing scripts like this is really dangerous though. 执行这样的脚本真的很危险 。
What I really wanted is to execute the file on the webserver itself. 我真正想要的是在Web服务器本身上执行该文件。 Luckily, I had help from some more experienced guys, who helped me on installing python on the webserver en executing my script from my own computer using ssh. 幸运的是,我得到了一些经验丰富的人的帮助,他们帮助我在网络服务器上安装python并使用ssh从我自己的计算机上执行我的脚本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.