欢迎访问mehome的博客

Tomorrow is another day.
Fork me on GitHub
摘要: 一、str.format 按照指定格式格式化字符串,然后返回格式化的字符串,源字符串不变。 以下是Python2.7环境。 1.1、按照位置替换 参考下面例子:>>> s = '{0} is {1}' >>> s.format('wo','haoren') 'wo is haoren' >>> s '{0} is {1}' >>> s = '{} {} age.' >>> s.format('wo... 阅读全文
posted @ 2018-08-16 22:17 mehome 阅读(1652) 评论(0) 推荐(0) 编辑
摘要: 一、常用方法集合 1.1、string,字符串常用方法 以下举例是python2.7测试: 函数名称 作用 举例 str.capitalize() 字符串第一个字符如果是字母,则把字母替换为大写字母。然后返回新的字符串 >>> l = 'abc cba' >>> l.capitalize() 'Abc cba' >>> l.capitalize() '2b 3c' str... 阅读全文
posted @ 2018-08-16 21:13 mehome 阅读(688) 评论(0) 推荐(0) 编辑
摘要: 一、常用方法 1.1、int 以下是Python2.7的int内置函数: 序号 函数名 作用 举例 1 int.bit_length() 二进制存储这个整数至少需要多少bit(位)。 >>> l.bit_length() 1 >>> l = 2 >>> l.bit_length() 2 >>> bin(2) '0b10' >>> l = 1024 >>> ... 阅读全文
posted @ 2018-08-16 20:44 mehome 阅读(942) 评论(0) 推荐(0) 编辑