我交流編碼器,但是Python是differrent,我遇到了一個問題,關於這個如何在...中連接字符串? (蟒蛇)
items = [
["/ank/homepage.py","Home"],
["/ank/package.py","Packages"],
["/status.py","Status"],
["/task.py","Task"],
["/report.py","Report"]
]
static_html='<table id="main_nav" align="center"><tr>'
for each_item in items:
if each_item in items:
if isinstance(each_item, list):
static_html= static_html + '<td><a href=" ', each_item[0], ' "> ', each_item[1], ' </a></th> '
static_html+='</tr></table>'
print static_html
屆時,IDE給我一個錯誤/usr/bin/python2.7
/home/tsuibin/code/aps/dxx/test_tmp.py
Traceback (most recent call last):
File "/home/tsuibin/code/aps/dxx/test_tmp.py", line 39, in <module>
printMainNavigation()
File "/home/tsuibin/code/aps/dxx/test_tmp.py", line 20, in printMainNavigation
static_html= static_html + '<td><a href=" ', each_item[0], ' "> ', each_item[1], ' </a></th> '
TypeError: can only concatenate tuple (not "str") to tuple
Process finished with exit code 1
有人格式化你的代碼,而現在你又搞砸了:)(現在的罰款) –