嗯,学习其它语言没这样全练过,嘻嘻

//test.py

1 # -*- coding: UTF-8 -*-
2
3 str = "i am worker"
4 print str.capitalize()
5 print str.center(20)
6 print str.count(' ')
7 print str.count(' ', 0, 4)
8 str1 = "中国"
9 str1.decode('utf-8').encode('gb2312')
10 print str1
11 str2 = u'中国'
12 str2.encode('gb2312')
13 print str2
14 print str.endswith('er')
15 print str.endswith('er', 0, 6)
16 str3 = '1 3 5'
17 print str3
18 print str3.expandtabs()
19 print str3.expandtabs(1)
20 print str.find('m', 0, len(str))
21 #print str.index('h', 0, len(str)) #exception
22 print ''.isalnum()
23 print '?1a'.isalnum()
24 print '1a'.isalnum()
25 print '1'.isalpha()
26 #print 'isdecimal', '1a'.isdecimal() #no implement
27 print 'isdigit', '1a'.isdigit()
28 #print 'isnumeric', '1a'.isnumeric() #no implement
29 print 'islower', '1a'.islower()
30 print ' '.isspace()
31 print 'You are fool'.istitle()
32 print 'You Are Fool'.istitle()
33 print '1a'.isupper()
34 print 'and'.join(['1', '2', '3'])
35 print '123'.ljust(10) #make no sense of
36 print 'ABC'.lower()
37 print 'abc'.upper()
38 print ' abAB'.lstrip()
39 #print '123abc'.maketrans('123', 'ABC') #no implement
40 print '123'.partition('2')
41 print '123'.partition('1')
42 print '123'.partition('3')
43 print '123'.partition('4')
44 print '113'.replace('1', '2')
45 print '113'.replace('1', '2', 1)
46 print '11a'.rfind('a')
47 print '11a'.rindex('a')
48 print '123'.rjust(8)
49 print '123'.rpartition('2')

50 print '123 '.rstrip()
51 print '12134'.split('1')
52 print '12134'.split('1', 1)
53 print '1\r2\r\n3\n'.splitlines(True)
54 print '1\r2\r\n3\n'.splitlines(False)
55 print '123'.startswith('1')
56 print ' 123 '.strip()
57 print 'AbAbAb'.swapcase()
58 print 'abc def hgj'.title()
59 print '1aAbB?><'.translate(None, '<>')
60 print '123'.zfill(8)
61 print u'123'.isdecimal()
62 print u'AEBF'.isdecimal()

//result

# python test.py
I am worker
i am worker
2
1
中国
中国
True
False
1 3 5
1 3 5
1 3 5
3
False
False
True
False
isdigit False
islower True
True
False
True
False
1and2and3
123
abc
ABC
abAB
('1', '2', '3')
('', '1', '23')
('12', '3', '')
('123', '', '')
223
213
2
2
123
('1', '2', '3')
123
['', '2', '34']
['', '2134']
['1\r', '2\r\n', '3\n']
['1', '2', '3']
True
123
aBaBaB
Abc Def Hgj
1aAbB?
00000123
True

False

Finally:

肯定有你用得着的

python string method的更多相关文章

  1. Python string objects implementation

    http://www.laurentluce.com/posts/python-string-objects-implementation/ Python string objects impleme ...

  2. python string module

    String模块中的常量 >>> import string >>> string.digits ' >>> string.letters 'ab ...

  3. python string

    string比较连接 >>> s1="python string" >>> len(s) 13 >>> s2=" p ...

  4. The internals of Python string interning

    JUNE 28TH, 2014Tweet This article describes how Python string interning works in CPython 2.7.7. A fe ...

  5. Python string replace 方法

    Python string replace   方法 方法1: >>> a='...fuck...the....world............' >>> b=a ...

  6. Python string interning原理

    原文链接:The internals of Python string interning 由于本人能力有限,如有翻译出错的,望指明. 这篇文章是讲Python string interning是如何 ...

  7. [Python] String Join

    Let's introduce a new string method, join: >>> nautical_directions = "\n".join([& ...

  8. [Python] String Formatting

    One particularly useful string method is format. The format method is used to construct strings by i ...

  9. [Python] String strip() Method

    Description The method strip() returns a copy of the string in which all chars have been stripped fr ...

随机推荐

  1. MySql 远程连接的条件

    1.首先看服务器防火墙 引用:http://www.cnblogs.com/silent2012/archive/2015/07/28/4682770.html CentOS 7.0默认使用的是fir ...

  2. ubuntu16.04编译安装imu_tk

    imu_tk代码地址 https://bitbucket.org/alberto_pretto/imu_tk 安装依赖项 sudo apt-get install build-essential cm ...

  3. python数据结构之图论

    本篇学习笔记内容为图的各项性质.图的表示方法.图ADT的python实现 图(Graph) 是数据结构和算法学中最强大的框架之一(或许没有之一).图几乎可以用来表现所有类型的结构或系统,从交通网络到通 ...

  4. static的含义

    static的含义:(1)设置变量的存储域,函数体内static变量的作用范围为该函数体,不同于auto变量,该变量的内存只被分配一次,因此其值在下次调用时仍持上次的值:(2)限制变量的作用域,在模块 ...

  5. [development][dpdk][pktgen] 网卡收发包性能测试-详细数据

    三层包测试 发包方式:192.168.20.205 发包工具:pktgen 发包网卡:i350 收包设备:1922.168.20.185 CPU:Intel(R) Xeon(R) CPU E5-262 ...

  6. git bash 命名

    git log -p -2 我们常用 -p 选项展开显示每次提交的内容差异,用 -2 则仅显示最近的两次更新. git diff HEAD git clean -df 恢复到最后一次提交的改动: gi ...

  7. Java基础知识之集合

    Collection集合 特点:长度可变,只能存储引用类型,可以存储不同的类型的元素 list 特点:元素有序(存储和取出的顺序一致),元素可以重复.list除了可以用迭代器循环遍历之外,因为其是有序 ...

  8. 浏览器数据库 IndexedDB 入门教程

    一.概述 随着浏览器的功能不断增强,越来越多的网站开始考虑,将大量数据储存在客户端,这样可以减少从服务器获取数据,直接从本地获取数据. 现有的浏览器数据储存方案,都不适合储存大量数据:Cookie 的 ...

  9. schtasks 命令使用

    schtasks  /create 创建任务,下面是常用参数 /tn taskname /tr taskrun /sc schedule    [Minute | Hourly | Daly | We ...

  10. 经典影响力传播模型LT模型、IC模型

    一.LT模型:线性阈值模型 思想:当一个已经激活的节点去试图激活邻居节点而没有成功时,其对邻居节点的影响力被累积而不是被舍弃,这个贡献直到节点被激活或传播过程结束为止.该过程称为‘影响累积’. 过程: ...