我有从外部配置文件读取凭证的代码,
configParser = ConfigParser.RawConfigParser()
configFilePath = r'docs/credentials.cfg'
configParser.read(configFilePath)和
User = configParser.get('your-config', 'user')
Pswd = configParser.get('your-config','pswd')
Host = configParser.get('your-config','hostdps')
db = pymysql.connect(host=Host, user=User, password=Pswd, db='xyz', charset='utf8mb4', cursorclass=pymysql.cursors.DictCursor,local_infile=True)密码包含特殊字符,如:#?f8h!3,如何使connect语句理解这些字符。
我已经尝试添加反斜杠,在连接字符串中传递它,不确定如何获得它?
发布于 2017-02-21 19:29:28
错误是在配置文件中密码字符串的开头添加引号。
我使用的是: configParser = ConfigParser.RawConfigParser(),所以它将“视为密码的一部分”。
真的很傻。
https://stackoverflow.com/questions/42364530
复制相似问题