python3常见的字符串格式化方式 NMEMTF 2021-11-11 97 阅读1分钟 """常见的字符串格式化有哪几种?""" #1. 占位符 name = 'peter' str = "%s hello world!" %name #2. format str = "{} hello world!".format(name) #3. f-string (python3.6之后才有的特性) str = f"{name} hello world!"