(1) print "First number is {} and second number is {}".format(first, second)
(1b) print "First number is {first} and number is {second}".format(first=first, second=second)
或者
(2) print 'First number is', first, ' second number is', second
或者
(3) print 'First number %d and second number is %d' % (first, second)
或者
(4) print 'First number is' + str(first) + 'second number is' + str(second)
你可以这样做(可能还有其他方法):
或者
或者
或者
如果可用,最好使用format()(1/1b)。
您还可以从Here学习字符串格式
是的。首选语法是支持
str.format
,而不是不推荐的%
运算符。相关问题 更多 >
编程相关推荐