【问题标题】:How do I connect to Python program from another Python program on another computer?如何从另一台计算机上的另一个 Python 程序连接到 Python 程序?
【发布时间】:2016-05-19 23:59:10
【问题描述】:

我的问题包含更多细节,但底线是我需要大致了解如何从另一台计算机上的另一个程序调用我的其他 Python 程序(或函数),我需要什么(即套接字?) 我正在做的是构建一个 Python UI 应用程序,该应用程序应连接到在 RPi 上运行的 Raspberry Pi Python GPIO 脚本以控制引脚(即 LED),我不确定这些细节是否相关,但最重要的是如何基本让两个程序互相对话?

【问题讨论】:

  • 你有 ssh 访问树莓派的权限吗?
  • 当然可以,我也想过,只是不知道如何让两个程序都说话

标签: python computer-science raspberry-pi2 gpio


【解决方案1】:

Paramiko 库可能是这里的解决方案之一:

import paramiko

ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(host, username=username, password=password, port=port, timeout=30)  # setting up ssh connection 
ssh.exec_command('<Execute Your Remote Script here>')
ssh.close()

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-06-28
  • 2013-01-16
  • 2023-03-12
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多