我正在编写一个CLI实用程序来用于更新Drupal模块。
在我的脚本未达到if()
条件的过程中,我遇到了障碍:
if(confirm_delete == 'Yes'):
print 'Will delete ' + to_delete_modules.split(',')
我得到的输出如下:
我试图让它打印下面的行,而不是点击except
声明
print 'Will delete ' + to_delete_modules.split(',')
有人看到有什么东西在这里徘徊吗?
答案 0 :(得分:4)
您的行中有TypeError: cannot concatenate 'str' and 'list' objects
'Will delete ' + to_delete_modules.split(',')
您不能将'str'与to_delete_modules.split(',')
返回的'list'连接起来。
如果您打印出异常,您应该能够看到该错误消息:
try:
...
print 'Will delete ' + to_delete_modules.split(',')
except Exception as e:
print 'An error occured, please contact author.'
print e # TypeError: cannot concatenate 'str' and 'list' objects