小编Lou*_*ino的帖子

TypeError:无法连接'str'和'dict'对象

我是该领域的新手,我想创建一个有用且快速处理的程序,并运行此脚本,我收到此错误,我无法得到此错误.

# -*- coding: cp1252 -*-
import ftplib, os
from ftplib import FTP 

def getFTPConfig(FTPLib):
    if os.path.exists("./incluide/Config.json"):
        with open("./incluide/Config.json") as ConfigFTP:
            FTPConnect = ConfigFTP.read()
    else:
        os.system("title Config FTPConnect")
        Host = raw_input("Enter the host: ")
        Login = raw_input("Enter the login: ")
        Pass = raw_input("Enter de password: ")
        file = open("./incluide/Config.json", "wb")
        file.write('''{"Host": "'''+Host+'''",
 "Login: "'''+Login+'''",
 "Pass: "'''+Pass+'''"}''')
        file.close()
        print "Successfully created"
        os.system("FTP Session")
    try:
        FTPs = json.loads(FTPConnect)
        return FTPs[FTPLib]
    except:
        return {}

    with open("./incluide/Config.json") as ConfigFTP:
        FTPConnect = ConfigFTP.read()
        print('Conectando ao …
Run Code Online (Sandbox Code Playgroud)

python python-2.7

2
推荐指数
2
解决办法
2万
查看次数

标签 统计

python ×1

python-2.7 ×1