python 格式化字符串

 

 

1、元组形式

print('hello %s and %s' % ('df', 'another df'))

 

2、字典形式

print('hello %(first)s and %(second)s' % {'first': 'df', 'second': 'another df'})

 

3、format

print('hello {first} and {second}'.format(first='df', second='another df'))

 

posted @ 2018-12-21 23:50  Operater  阅读(175)  评论(0)    收藏  举报