Python-字符串操作 Python 2023/01/03 字符串相关操作 连续空格去重 123456import rere.sub(r'\s+', ' ', 'a b c d')结果:a b c d 格式化 123456789s = 'hello {}'.format('zhangsan')print(s)s = 'hello {0}, where is {1}, {0}?'.format('zhangsan', 'lisi') print(s)结果:hello zhangsanhello zhangsan, where is lisi, zhangsan?
评论系统未开启,无法评论!