立即学习:https://edu.youkuaiyun.com/course/play/26676/338776?utm_source=blogtoedu
split()
.join()
字符串的格式化输出
“I like {0} and {1}”.format("python","physics")
设置格式{0:10}10表示字符串长度
{0:>10}>大于号右对齐
{0:^10}^居中
{0:10d}d字符类型整数
{0:.1f}浮点数一位
dir()
help()
Python字符串格式化完全指南
本文详细介绍了Python中字符串格式化的各种方法,包括使用.format()进行基本格式化,设置字符串长度,对齐方式,以及指定数据类型如整数、浮点数的显示格式。通过实例演示了如何灵活运用这些技巧来美化输出。
立即学习:https://edu.youkuaiyun.com/course/play/26676/338776?utm_source=blogtoedu
split()
.join()
字符串的格式化输出
“I like {0} and {1}”.format("python","physics")
设置格式{0:10}10表示字符串长度
{0:>10}>大于号右对齐
{0:^10}^居中
{0:10d}d字符类型整数
{0:.1f}浮点数一位
dir()
help()

被折叠的 条评论
为什么被折叠?