Python 字符串格式化方法_python 字符串 格式化-CSDN博客

网站介绍:1.使用format(arg)方法将字符串中用 {} 定义的替换域依次用参数arg中的数字替换In[1]: 'hello,{}'.format('world!')Out[1]:'hello,world!'In[2]: '{},{},{}'.format(1,2,4)Out[2]:'1,2,4'In[3]: '{0},{1},{0}'.format(1,2,4) #指定替换域Out[3]:'1,2,1' 2.使用%方法格式化字符串%(参数1,参数2......_python 字符串 格式化