Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 当结果返回“/images/”时,RawConfigParser.get().endswith(“/”)为False?应该是真的_Python_Django - Fatal编程技术网

Python 当结果返回“/images/”时,RawConfigParser.get().endswith(“/”)为False?应该是真的

Python 当结果返回“/images/”时,RawConfigParser.get().endswith(“/”)为False?应该是真的,python,django,Python,Django,我将Django与我自己的配置文件加载器一起使用,它继承了Python内置的ConfigParser,并使用get方法 它是这样做的: from ConfigParser import RawConfigParser config = RawConfigParser() config.read(os.path.dirname(__file__) + '/settings.ini') # read the settings file MEDIA_URL = config.get('SETTINGS

我将Django与我自己的配置文件加载器一起使用,它继承了Python内置的ConfigParser,并使用get方法

它是这样做的:

from ConfigParser import RawConfigParser
config = RawConfigParser()
config.read(os.path.dirname(__file__) + '/settings.ini') # read the settings file
MEDIA_URL = config.get('SETTINGS', 'media_url') # which is verified to contain '/images/'

# then I expect this to return True, but get false?

print MEDIA_URL.endswith('/')
print type(MEDIA_URL) # get's "str"

# however this returns True
MEDIA_URL = '/images/'
print MEDIA_URL.endswith('/')
print type(MEDIA_URL) # get's "str"
现在,为什么两者都是字符串类型,但返回不同的值

它搞乱了我的django设置,在django.conf.init第70行抛出了一个错误


有什么线索吗?

你确定最后一个字符真的是a/吗,或者可能是?空格不,你是对的!事实证明,我有引号,ConfigParser包含引号。谢谢如果你发布这个,我会把它标记为答案。