python中typeerror是什么意思_TypeError:在Python中

时间:2025-04-07 09:37:33

我有一个问题,函数返回一个数字。当我试图组装一个包含该号码的URL时,我遇到了失败。在

具体来说,我得到的错误是TypeError: cannot concatenate 'str' and 'NoneType' objects

不知道从这里到哪里去。在

以下是相关代码:# Get the raw ID number of the current configuration

configurationID = generate_configurationID()

# Update config name at in Cloud

updateConfigLog = open(logBase+'change_config_name_log.xml', 'w')

# Redirect stdout to file

= updateConfigLog

(('put', baseURL+'configurations/'+configurationID+'?name=this_is_a_test_', user, token))

= sys.__stdout__

如果我手动将以下内容输入休息。休息()

^{pr2}$

我试过str(configurationID),它返回了一个数字,但我再也无法获得URL的其余部分。。。在

有什么想法?帮忙吗?在

好吧。。。为了显示我的baseURL和configurationID,我做了些什么。在print 'baseURL: '+baseURL

print 'configurationID: '+configurationID

这是我得到的it-tone:trunk USER$ ./ fresh

baseURL: /

369596

Traceback (most recent call last):

File "./", line 173, in

main()

File "./", line 30, in main

fresh()

File "./", line 162, in fresh

updateConfiguration()

File "./", line 78, in updateConfiguration

print 'configurationID: '+configurationID

TypeError: cannot concatenate 'str' and 'NoneType' objects

it-tone:trunk USER$

我感兴趣的是369596是配置ID,但和以前一样,它似乎会破坏它周围的所有调用。在

正如kindall在下面指出的,我的generate_configurationID并不是返回值,而是打印它。在# from generate_configurationID

def generate_configurationID():

dom = parse(logBase+'provision_template_log.xml')

name = ('id')

p = name[0].

print p

return p