1. 程式人生 > >2017-12-18python全棧9期第三天第二節之str常用操作方法及for迴圈格式化輸出三種玩法format

2017-12-18python全棧9期第三天第二節之str常用操作方法及for迴圈格式化輸出三種玩法format

#!/user/bin/python
# -*- coding:utf-8 -*-
s = '我叫{},今年{},愛好{},再說一下我叫{}'.format('zd',24,'xq','zd')
print(s)
s = '我叫{0},今年{1},愛好{2},再說一下我叫{0}'.format('zd',24,'xq')
print(s)
s = '我叫{name},今年{age},愛好{hobby},再說一下我叫{name}'.format(name='zd',age=
24,hobby='xq')
print(s)