Python的字符串格式化常用的有三種!
第一種:最方便的
缺點:需一個個的格式化
print('hello %s and %s'%('df','another df'))
第二種:最好用的
優點:不需要一個個的格式化,可以利用字典的方式,縮短時間
print('hello %(first)s and %(second)s'%{'first':'df' , 'second':'another df'})
第三種:最先進的
優點:可讀性強
print('hello {first} and {second}'.format(first='df',second='another df'))