我有一个程序可以像这样从数组中打印出字符串:
for x in strings
print x,
效果很好,所有字符串都打印在同一行上,这正是我想要的,但随后我还必须在新行上打印出不属于数组的字符串。像这样:
for x in strings:
print x,
print second_name
最终所有打印都在同一行上。不过,我希望 second_name 在换行符上打印,我该怎么做?
最佳答案
使用换行符\n
:
print '\n' + second_name
关于Python 在新行打印语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20870744/