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'))

猜你喜欢

转载自www.cnblogs.com/z-x-y/p/10159568.html