简体   繁体   English

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

[英]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.

相关问题 如何在 Windows 7 的命令提示符中运行 Python 程序? - How do I run a Python program in the Command Prompt in Windows 7? 如何从 windows 命令提示符在虚拟环境中运行 python 程序? - How do I run a python program in a virtual environment from windows command prompt? 尝试从命令提示符运行 Python 程序 - Trying to run Python program from command prompt Python,尝试从命令提示符运行程序 - Python, trying to run a program from the command prompt 如何在 Windows 命令提示符下运行 python 文件? - How to run a python file in the windows command prompt? 无法通过Windows命令提示符运行简单的Python程序 - Cant make simple Python program run through Windows command prompt 如何从Windows命令提示符运行Openscad - How to run Openscad from windows command prompt 如何从 windows 命令提示符中杀死 python? - how to kill python from windows command prompt? 我无法从命令提示符运行 Sublime Text 3 Python 程序 - I cannot run a Sublime Text 3 Python program from Command Prompt Python:无法使用Python脚本打开新的命令提示符会话并通过命令行(Windows)运行程序 - Python: Unable to open a new command prompt session and run a program through command line (windows) using Python script
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM