具体代码如下:
age = 20
name = 'Swaroop'
print('{0} was {1} years old when he wrote this book'.format(name, age))
print('Why is {0} playing with that python?'.format(name))
输出:
$ python str_format.py Swaroop was 20 years old when he wrote this book Why is Swaroop playing with that python?
我想问一下python的索引从0开始 那么0不应该是age 1不应该是name吗?