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

//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. easyui---修改删除查询

    修改:在toolsbar 修改工具中 { text:"编辑用户", iconCls:"icon-edit", handler:function(){ var s ...

  2. poj3613 Cow Relays【好题】【最短路】【快速幂】

    Cow Relays Time Limit: 1000MS   Memory Limit: 65536K Total Submissions:9207   Accepted: 3604 Descrip ...

  3. A股行情记录

    14年:券商 + 高铁 15年:大牛 16年:钢铁,煤炭(去产能) 17年:消费,大白马(去杠杆) 18年:科技股,垃圾股(股权质押),科创板 19年:券商 + 大金融 + 科技股 ?

  4. synchronized 同步代码块,售票问题

    package cn.ljs.FristSync; public class SalerDemo extends Thread { static int tickets = 1000; String ...

  5. [No0000144]深入浅出图解C#堆与栈 C# Heap(ing) VS Stack(ing)理解堆与栈1/4

    前言   虽然在.Net Framework 中我们不必考虑内在管理和垃圾回收(GC),但是为了优化应用程序性能我们始终需要了解内存管理和垃圾回收(GC).另外,了解内存管理可以帮助我们理解在每一个程 ...

  6. 一个按成绩排序SQL的写法问题

    测试数据: SQL> select * from sscore; NAME       SCORE ---------- ----- aa            99 bb            ...

  7. 2016年蓝桥杯省赛A组c++第8题(暴力求解)

    /* 四平方和定理,又称为拉格朗日定理: 每个正整数都可以表示为至多4个正整数的平方和. 如果把0包括进去,就正好可以表示为4个数的平方和. 比如: 5 = 0^2 + 0^2 + 1^2 + 2^2 ...

  8. 用github搭建网站

    写在前面:本博客为本人原创,严禁任何形式的转载!本博客只允许放在博客园(.cnblogs.com),如果您在其他网站看到这篇博文,请通过下面这个唯一的合法链接转到原文! 本博客全网唯一合法URL:ht ...

  9. Java中抽象类和抽象方法的区别

    抽象方法:在类中没有方法体的方法,就是抽象方法. 抽象类:含有抽象方法的类就叫抽象类. 抽象类中的抽象方法必须被实现! 如果一个子类没有实现父类中的抽象方法,则子类也成为了一个抽象类! 抽象类中的普通 ...

  10. day5_集合

    集合也是一种数据类型,一个类似列表东西,它的特点是无序的,不重复的,也就是说集合中是没有重复的数据 集合的作用: 1.它可以把一个列表中重复的数据去掉,而不需要你再写判断---天生去重 2.可以做关系 ...