简体   繁体   中英

How in python's module CONFIGPARSER read text from variable, not from a file?

The problem is that config.read("filename.ini") - requires a local file. I download the content of this file straight into the variable from my FTP server with the help of StringIO.

content = StringIO()
f.retrbinary('RETR /folder1/inifile.ini, content.write)
request = content.getvalue()
config.read(request)

I found this in the python docs.

Using your StringIO object it looks like you can use config.readfp(contents).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM