2024-04-26 14:43:00 发布
网友
更具体地说,我正试图以类似soprint str(function(first)) + str(function(second)) + str(function(third))等句子的形式打印函数的几个结果,但我遇到了一个问题,即各个字符串之间没有空格。你知道吗
print str(function(first)) + str(function(second)) + str(function(third))
所以,我想知道的是如何在每个字符串之间添加空格。你知道吗
print function(first), function(second), function(third)
或使用字符串格式:
print '{0} {1} {2}'.format(function(first), function(second), function(third))
print str(function(first)) + ' ' + str(function(second)) + ' ' + str(function(third))
使用join()
join()
print " ".join([str(function(first)), str(function(second)), str(function(third))])
或使用字符串格式:
使用
join()
相关问题 更多 >
编程相关推荐