str()如何在python中实现?

时间:2019-02-17 13:18:25

标签: python concatenation

储蓄和结果的定义

savings = 100
result = 100 * 1.10 ** 7

修复打印结果

print("I started with $" + savings+  " and now have $" + result+  " Awesome!")

pi_string的定义

pi_string = "3.1415926"

1 个答案:

答案 0 :(得分:-1)

您可以将int s转换为str s,如下所示:

print("I started with $" + str(savings)+  " and now have $" + str(result)+  " Awesome!")

或使用这样的字符串格式:

print("I started with ${} and now have ${} Awesome!".format(savings, result))