我使用Python将SQLite3数据库中的数据追加到数组中。现在我有了一个数组,我正试图以如下格式打印附加数据:print "Team: " + new_array[0][0] + " Score: " + new_array[0][1] + " Overall: " + new_array[0][2]
我已经准备好的代码就可以了。但是,我尝试使用计数器创建一个循环,该计数器将以上述格式打印数组中的所有数据。在
问题是,当我尝试创建一个for循环并打印数组中的第一个值时,只打印该值的第一个字母。例如:
^{pr2}$
。。。将打印:team_6
team_3
team_5
team_1
team_2
team_4
。。。还有。。。在print new_array[0][0]
。。。将打印:t
t
t
t
t
t
到目前为止,我得到的是:
导入sqlite3new_array = []
conn = sqlite3.connect('league.db')
c = conn.cursor()
game = c.execute("SELECT Team,Score,Overall FROM League ORDER BY Overall DESC")
for items in game:
new_array.append(items)
print new_array[0][0]
上面的代码将按要求打印出“team_6”。但是,只有在创建for循环时才会出现打印问题。在
你的帮助将不胜感激。谢谢。在