python基础_格式化输出(%用法和format用法) name = 'jack' age = 18 sex = 'man' job = "IT" salary = 9999.99 print(f'my name is {name.capitalize()}.') print(f'I am {age:*^10} years old.') print(f'I am a {sex}') print(f'My salary is {salary:10.3f}') # 结果 my name…
平台:win10 x64+Python3.7.0 先了解下——Python3 字符串格式化 Python字符串的格式化方法分为两种,分别为占位符(%)和format方式. 占位符方式在Python2.x中用的比较广泛,format方式在Python3.x使用的更加广泛. 一 .占位符(%) %d age = 29 print("my age is %d" %age) #my age is 29 实例一 %s name = "makes" print("m…