for lan in songs_language: sql = ''' select count(list_tags),sum(song_count),sum(play_count),sum(star_count),sum(share_count),sum(comment_count) from (select list_tags,star_count,share_count,comment_count,song_count,play_count from playlist_info where list_tags like '%{lan}%');'''.format(lan=lan) table = spark.sql(sql) for row in table: count_list.append(row[0]) count_song.append(row[1]) count_play.append(row[2]) count_star.append(row[3]) count_share.append(row[4]) count_comment.append(row[5]) 如何打印出列表中的值,而不是对象
时间: 2024-04-13 13:28:26 浏览: 146
要打印出列表中的值而不是对象,你可以使用循环遍历列表,并使用`print`函数打印每个元素的值。在你的代码中,你可以像这样修改循环部分:
```python
for row in table:
count_list.append(row[0])
count_song.append(row[1])
count_play.append(row[2])
count_star.append(row[3])
count_share.append(row[4])
count_comment.append(row[5])
# 打印列表中的值
print("count_list:", count_list)
print("count_song:", count_song)
print("count_play:", count_play)
print("count_star:", count_star)
print("count_share:", count_share)
print("count_comment:", count_comment)
```
这样,列表`count_list`、`count_song`、`count_play`、`count_star`、`count_share`和`count_comment`中的值将被打印出来。确保在需要打印值的位置使用适当的缩进,并在变量名后添加冒号和空格。
阅读全文