84669 personnes étudient
152542 personnes étudient
20005 personnes étudient
5487 personnes étudient
7821 personnes étudient
359900 personnes étudient
3350 personnes étudient
180660 personnes étudient
48569 personnes étudient
18603 personnes étudient
40936 personnes étudient
1549 personnes étudient
1183 personnes étudient
32909 personnes étudient
如题:paramiko怎么判断远程目录是否存在?在调用exec_command函数的时候,怎么判断远程目录是否存在呢? 因为这里不能传if进去。
小伙看你根骨奇佳,潜力无限,来学PHP伐。
可以使用笨一点方法,运行一些对目录检测的命令,如ls,然后去检测输出!
stdin,stdout,stderr = client.exec_command('ls DIR') if stdout.readline() != '': print("exist") else: print("not exist")
方法二:使用sftp, 不使用exec_command
sftp = client.open_sftp() try: sftp.stat(path) print("exist") except IOError: print("not exist")
可以使用笨一点方法,运行一些对目录检测的命令,如ls,然后去检测输出!
方法二:
使用sftp, 不使用exec_command