在PHP中,可以写:
$fruit = 'Pear';
print("Hey, $fruit!");
Run Code Online (Sandbox Code Playgroud)
但在Python中它是:
fruit = 'Pear'
print("Hey, {0}!".format(fruit))
Run Code Online (Sandbox Code Playgroud)
有没有办法让我在字符串中插入变量?如果没有,这更加pythonic怎么样?
获得参考的任何人的奖励积分