zoukankan      html  css  js  c++  java
  • 40、常用字符串格式化有哪几种?

    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'))
  • 相关阅读:
    Arr
    class4
    class3联大网页
    class33
    class3
    人机交换 NO 1书签
    大数据的框架与特点
    mapreduce排序
    mapreduce求平均数
    mapreduce去重
  • 原文地址:https://www.cnblogs.com/zhuifeng-mayi/p/9215546.html
Copyright © 2011-2022 走看看