简体   繁体   English

python ConfigParser模块

[英]python ConfigParser module

I have the following ini file 我有以下ini文件

[Section]
value=test

When i use the ConfigParser Module : 当我使用ConfigParser模块时:

import ConfigParser
config = ConfigParser.ConfigParser()
config.read('config.ini')
str=config.get('Section', 'value')

if str == 'test':
    print 1

else :
    print 0

it always print 0 could someone help 它总是打印0有人可以帮忙吗

try 尝试

print str

and see what the value is. 看看值是多少

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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