如何从Windows命令提示符运行远程Python程序

时间:2013-08-26 16:55:19

标签: python remote-server

我的网站上有一个应用程序,我在Windows命令提示符下使用Python运行它。

当我尝试打开它时,

python http://www.erickwilts.nl/apps/app.py

它说:

python: can't open file 'http://www.erickwilts.nl/apps/app.py': [Errno 22] Invalid argument

我有办法做到这一点吗?

2 个答案:

答案 0 :(得分:2)

由于资源位于网络服务器上,因此您必须先将其下载。 您可以使用urllib2

执行此操作
import urllib2
exec(urllib2.urlopen("http://www.erickwilts.nl/apps/app.py").read())

执行这样的脚本虽然 非常危险

答案 1 :(得分:0)

我真正想要的是在网络服务器上执行该文件。幸运的是,我得到了一些经验丰富的人的帮助,他们帮助我在网络服务器上安装python并使用ssh从我自己的计算机上执行我的脚本。

相关问题