【问题标题】:How to read file from server using python如何使用python从服务器读取文件
【发布时间】:2021-08-29 22:44:14
【问题描述】:

我想从我的服务器读取一个 json 文件:103.227.176.29 但收到错误“invalid literal for int() with base 10: '103.227.176.29”我不知道如何解决它。 我该怎么做才能解决这个问题?

from contextlib     import closing
from fabric.network import connect
user = 'cortekr1_cuong' 
password = '12345678'
host = '103.227.176.29' 
port = '3306' 
remote_file = '/RBICloudv1/static/json/vietnamprovince/vn.json'
with closing(connect(user, password, host, port)) as ssh, \
     closing(ssh.open_sftp()) as sftp, \
     closing(sftp.open(remote_file)) as file:
    for line in file:
      print(line) 

【问题讨论】:

  • 这篇文章会回答你的问题:stackoverflow.com/questions/62850543/…
  • 发布回溯。我们不必猜测错误在哪里。
  • 请提供足够的代码,以便其他人更好地理解或重现问题。

标签: python server sftp fabric


【解决方案1】:

密码不是参数,因此您尝试将主机作为端口传递,它不是数字

https://docs.fabfile.org/en/1.12.1/api/core/network.html#fabric.network.connect

顺便说一下,3306端口是mysql常用的,不是sftp服务器

【讨论】:

    猜你喜欢
    • 2018-01-26
    • 2010-12-08
    • 2011-05-08
    • 1970-01-01
    • 2011-05-30
    • 2019-10-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多