首页 > 其他 > 详细

40、常用字符串格式化有哪几种?

时间:2018-06-22 22:21:33      阅读:288      评论:0      收藏:0      [点我收藏+]

Python的字符串格式化常用的有三种!

  第一种最方便的

  缺点:需一个个的格式化

print(hello %s and %s%(df,another df))

 

  第二种最好用的

  优点:不需要一个个的格式化,可以利用字典的方式,缩短时间

print(hello %(first)s and %(second)s%{first:df , second:another df})

  第三种最先进的

    优点:可读性强

print(hello {first} and {second}.format(first=df,second=another df))

 

40、常用字符串格式化有哪几种?

原文:https://www.cnblogs.com/zhuifeng-mayi/p/9215546.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!