我在Ubuntu上编写了一个python程序。在那个程序中,我正努力在连接RaspberryPi的远程网络上使用命令askopenfilename
选择一个文件。从Python中的远程计算机中选择文件
任何人都可以指导我如何使用askopenfilename
命令或类似的东西在远程机器选择一个文件?
from Tkinter import *
from tkFileDialog import askopenfilename
import paramiko
if __name__ == '__main__':
root = Tk()
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect('192.168.2.34', username='pi', password='raspberry')
name1= askopenfilename(title = "Select File For Removal", filetypes = [("Video Files","*.h264")])
stdin, stdout, stderr = client.exec_command('ls -l')
for line in stdout:
print '... ' + line.strip('\n')
client.close()
用'sshfs'挂载远程文件系统是否更加可行,以便远程文件可以作为本地文件访问?您似乎已经拥有了ssh访问权限。 – 2015-02-10 15:56:13
@RafaelLerm我该怎么做 – 2015-02-10 15:57:12
@ IrfanGhaffar7这取决于您在计算机上使用的操作系统。例如,Google上有[Windows 8手册](http://igikorn.com/sshfs-windows-8/)。只是谷歌“如何安装sshfs(您的操作系统)”。 – 2015-02-10 16:04:56