#coding=utf8
def format(self, *args, **kwargs): # known special case of str.format
"""
S.format(*args, **kwargs) -> string Return a formatted version of S, using substitutions from args and kwargs.
The substitutions are identified by braces ('{' and '}').
"""
pass
test = 'liuzhipeng age = {age}, name = {name}, sex = {sex}'
print test
print test.format(age=10, name="liuzhipeng", sex="male")

[python][oldboy]字符串 format的更多相关文章

  1. Python格式化字符串--format

    format格式化字符串方法相较于老版%格式方法的优点: 1.不需要理会数据类型的问题,在%方法中'%s'只能替代字符串类型. 2.单个参数可以多次输出,参数顺序可以不相同. 3.填充方式十分灵活,对 ...

  2. Python里字符串Format时的一个易错“点”

    这是一篇很小的笔记,原因是我做学习通的时候见到了这个题: 当时看了一会儿发现没有符合自己想法的答案,然后就脑袋一热选了C,结果当然是错了... 看了一眼这个format的字符串对象,发现有个 {:7. ...

  3. python格式化字符串format函数

    1. format可以接受无限个的参数,位置可以不按顺序: In [1]: "{} {}".format("hello","world") ...

  4. python格式化字符串format的用法

    填充与对齐 填充常跟对齐一起使用 ^.<.>分别是居中.左对齐.右对齐,后面带宽度 :号后面带填充的字符,只能是一个字符,不指定的话默认是用空格填充 比如 In [15]: '{:> ...

  5. Python 的格式化字符串format函数

    阅读mattkang在csdn中的博客<飘逸的python - 增强的格式化字符串format函数>所做笔记 自从python2.6开始,新增了一种格式化字符串的函数str.format( ...

  6. Python 3.x 格式化输出字符串 % & format 笔记

    Python 3.x 格式化输出字符串 % & format 笔记 python格式化字符串有%和{}两种 字符串格式控制符. 字符串输入数据格式类型(%格式操作符号) %%百分号标记 %c字 ...

  7. 【转】Python格式化字符串str.format()

    原文地址:http://blog.xiayf.cn/2013/01/26/python-string-format/ 每次使用Python的格式字符串(string formatter),2.7及以上 ...

  8. python中字符串格式化%与.format

    Python的字符串格式化有两种方式: 百分号方式.format方式 百分号的方式相对来说比较老,而format方式则是比较先进的方式,企图替换古老的方式,目前两者并存.[PEP-3101] This ...

  9. 关于python字符串format的一些花式用法

    目录: 基础 实战 前提: python中字符串的format功能非常强大,可以说完全能够替代其他的字符串使用方法,但是在后期的项目开发中使用的并不是特别的多, 以至于想用的时候会想不起来准确的使用方 ...

随机推荐

  1. Elasticsearch-基本操作2

    Elasticsearch版本:6.0 为了避免并发修改的冲突问题,数据库中,经常用悲观锁和乐观锁来控制并发问题,而Elasticsearch使用乐观锁.如果源数据在读写过程中被修改,更新将失败,应用 ...

  2. Writable和Comparable

    WritableComparable接口相当于继承了上述两个接口的新接口 : Public interface WritableComparable<T>extends Writable, ...

  3. winform ListView创建columnHeader的方法

    using System; using System.Windows.Forms; using System.Drawing; using System.Collections; namespace ...

  4. 洛谷 P2380 狗哥采矿

    题目背景 又是一节平静的语文课 狗哥闲来无事,出来了这么一道题 题目描述 一个n*m的矩阵中,每个格子内有两种矿yeyenum和bloggium,并且知道它们在每个格子内的数量是多少.最北边有blog ...

  5. BZOJ 4777: [Usaco2017 Open]Switch Grass

    4777: [Usaco2017 Open]Switch Grass Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 46  Solved: 10[Su ...

  6. 无旋Treap【模板】P3369

    题目 详情见链接. 代码 #include<cstdio> #include<iostream> #define outd(x) printf("%d\n" ...

  7. Python 模块(二)

    1 logging 模块 logging有两种的配置的方式,configure.logger 1.1 config方式 import logging ''' 日志的配置:config模式 只能选择在屏 ...

  8. STM32F042开发板学习实践

    之前有粗略地学习过stm32F103的理论知识,但仅GPIO的配置.时钟配置就让人望而却步.现在手头有Nucleo STM32F042的开发板,而且ST已经推出STM32CubeMx图形化的工具软件, ...

  9. thinkphp的使用——隐藏index.php

    官方默认的.htaccess文件 <IfModule mod_rewrite.c>  Options +FollowSymlinks -Multiviews  RewriteEngine ...

  10. Android layout的XML

    [注]此文是在学习andriod中的一些理解和总结,若有错望留言指教,谢谢 1 <RelativeLayout xmlns:android="http://schemas.androi ...