1、出错代码
re_params = ' '
params = [ 'idc', 'name', 1]
re_params = re_params.join(params)
print re_params
2、得到报错
[ERROR] Traceback (most recent call last):
... ...
TypeError: sequence item 2: expected string, int found
这错误大致意思是: params 包含数字,因此不能直接把它转化成字符串。
3、解决方法
re_params = ' '
params = [ 'idc', 'name', 1]
re_params = re_params.join('%s' %id for id in params)
print re_params
正常输出结果:
idc name 1