我有一個代碼:蟒蛇:不能連接 '海峽' 和 '元組' 的對象(!它應該作品)
print "bug " + data[str.find(data,'%')+2:-1]
temp = data[str.find(data,'%')+2:-1]
time.sleep(1)
print "bug tuple " + tuple(temp.split(', '))
並在此之後我的應用程序顯示:
bug 1, 2, 3 Traceback (most recent call last): File "C:\Python26\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 312, in RunScript exec codeObject in main.dict File "C:\Documents and Settings\k.pawlowski\Desktop\atsserver.py", line 165, in print "bug tuple " + tuple(temp.split(', ')) TypeError: cannot concatenate 'str' and 'tuple' objects
我不知道我做錯了什麼。 打印元組('1,2,3'.split(','))正常工作。
如有疑問,請在互動翻譯器中進行測試! '>>>'ftw! – jathanism 2010-08-31 14:00:49