如何删除打印和用户编号之间的空格



Python中的老新手,我遇到了一个问题。

print('Adding the two numbers gives',user_num,', which is different from',str(number1 + number2),'.')

输出:

Adding the two numbers gives 24 , which is different from 1212 .

问题:如何删除24和逗号之间的空格,以及1212.之间的空格?

您可以使用sep关键字参数指定要print的分隔符。若要完全删除分隔符,请将其设置为空字符串。

print(number1, number2, sep='')

相关内容

最新更新