与PYTHON的ERRO:无法连接'str'和'list'对象

时间:2018-03-23 01:46:09

标签: python scripting ftplib

我尝试使用ftplib模块的登录方法连接到ftp服务器但是它会抛出此错误:

  <tr *ngFor="let ref of orderList">
      <td>{{order.id}}</td> 
      <span *ngFor="let order of ref.order; let first = isFirst">
      <td *ngIf="isFirst">{{order.parent}}</td>
      </span>  
    </tr>

我尝试执行的脚本如下:

File "conect.py", line 12, in (module)
  cod= conection.login(us, pa)
File "C:\Python27\lib\ftplib.py", line 394, in login
  resp = self.sendcmd('USER ' + user)
TypeError: cannot concatenate 'str' and 'list' objects

我不明白为什么我说如果我没有删除任何列表,我会将字符串与列表连接起来。

有谁知道问题出在哪里?

1 个答案:

答案 0 :(得分:1)

user.readlines()返回行列表。

因此,uspa都是列表,且类型不兼容。

要获取整个文件,请使用us.read()