简体   繁体   English

如何从网络计算机到本地主机运行python?

[英]How to run python from a network machine to local host?

I've a python script in the network machine, I can open the network through explorer and have access to the script. 我在网络计算机中有一个python脚本,我可以通过资源管理器打开网络并可以访问该脚本。 Through that script from network,I want to create some folders/files and write/read some files in my localhost. 通过网络中的脚本,我想在本地主机中创建一些文件夹/文件并写入/读取一些文件。 Is there a way to do this in python? 有没有办法在python中做到这一点?

The good part is: you have read access on the script. 好消息是:您对该脚本具有读取权限。

What you need is a python installation on your local machine and preferably a drive letter mapping to the script's folder. 您需要在本地计算机上进行python安装,最好是将驱动器号映射到脚本的文件夹。 If not already mapped, this can be scripted with net use <letter>: \\\\<remote host>\\<shared folder> . 如果尚未映射,则可以使用net use <letter>: \\\\<remote host>\\<shared folder>编写脚本。

Then it's as easy as cd <letter>:\\<path>\\ ; python <script>.py 然后就像cd <letter>:\\<path>\\ ; python <script>.py cd <letter>:\\<path>\\ ; python <script>.py . cd <letter>:\\<path>\\ ; python <script>.py

Then to the output of the script. 然后到脚本的输出。 Apparently it creates files. 显然,它创建文件。 Can you supply the target folder on the script's command line? 您可以在脚本的命令行中提供目标文件夹吗? In that case just supply a local path. 在这种情况下,只需提供本地路径即可。

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

相关问题 python:如何从EC2实例在本地计算机上运行命令 - python: How to run command on local machine from an EC2 instance 如何在 docker 容器中使用参数运行本地主机脚本 - How to run local host machine script with arguments in a docker container 如何在远程机器上运行本地python脚本 - how to run local python script on remote machine 如何使用 python 在网络中从一台机器运行任何应用程序到另一台机器 - How to run any application from one machine to another in network using python 如何从远程服务器上的本地计算机运行python脚本并实时显示输出? - How to run a python script from local machine on a remote server and display the outputs live? 如何在 AWS EC2 上运行 Python 代码并将 csv 文件从服务器写入我的本地计算机? - How to run a Python code on AWS EC2 and write a csv file from the server to my local machine? 通过 ssh 从远程 linux 机器运行本地 python 脚本 - run local python script from remote linux machine over ssh 如何从主机浏览器访问在 vagrant 中运行的 python? - How to access running python in vagrant from host machine browser? 从非本地网络机器连接到python开发Django服务器 - Connect to python development django server from a non-local network machine 从Windows主机在远程Linux机器上运行部分Python单元测试 - Run part of Python unit tests on remote Linux machine from a Windows host
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM