Skip to main content
 首页 » 编程设计

python之如何使用python在打印语句的for循环中插入换行符

2025年05月04日13jpfss

我正在使用下面的代码打印 twitter 中的好友列表

users = api.friends()
print([u.name for u in users])

我得到以下输出

['The New York Times', 'BBC Breaking News', 'Oprah Winfrey']

但是我想要这样的东西

['The New York Times',
'BBC Breaking News',
'Oprah Winfrey' ]

请您参考如下方法:

只是打破代码,写循环然后打印每个名字

for u in users: 
       print u.name 
       print ""