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

//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. TOP100summit:【分享实录-华为】微服务场景下的性能提升最佳实践

    本篇文章内容来自2016年TOP100summit华为架构部资深架构师王启军的案例分享.编辑:Cynthia 王启军:华为架构部资深架构师.负责华为的云化.微服务架构推进落地,前后参与了华为手机祥云4 ...

  2. 浏览器下载Excel,直接打开显示乱码...

    情景: 浏览器中点击下载文件有两个选项:[打开][下载] [打开]之后,提示["文件.xlsx"的文件格式和扩展名不匹配.文件可能已损坏或不安全.除非您信任其来源,否则请勿打开.是 ...

  3. Codeforces 279C - Ladder - [简单DP]

    题目链接:http://codeforces.com/problemset/problem/279/C 题意: 给出 $n$ 个整数 $a[1 \sim n]$,$m$ 个查询,对于一个查询 $[l_ ...

  4. [No0000EE]主要的宏观经济指标查询

    主要的宏观经济指标查询 国内:东财>经济数据 _ 数据中心:http://data.eastmoney.com/center/macro.html东财>经济数据 :http://data. ...

  5. zookeeper集群扩容/下线节点实践

    环境:zookeeper版本 3.4.6jdk版本 1.7.0_8010.111.1.29 zk110.111.1.44 zk210.111.1.45 zk310.111.1.46 zk410.111 ...

  6. 优化网站设计(七):避免在CSS中使用表达式

    前言 网站设计的优化是一个很大的话题,有一些通用的原则,也有针对不同开发平台的一些建议.这方面的研究一直没有停止过,我在不同的场合也分享过这样的话题. 作为通用的原则,雅虎的工程师团队曾经给出过35个 ...

  7. 2015年蓝桥杯省赛A组c++第5题(回溯算法填空)

    /* 1,2,3…9 这九个数字组成一个分数,其值恰好为1/3,如何组法? 下面的程序实现了该功能,请填写划线部分缺失的代码. */ #include <stdio.h> void tes ...

  8. [性能优化] perf 高级用法:完整记录程序性能指标,并按照时间段对程序进行有针对性的性能分析

    如题: 假设你已经熟悉了基本用法,知道perf是干嘛的,以及会用 perf top [性能优化] perf 背景:目标程序在运行的某时间段内会出现性能下降,需要了解这个时间内,程序发生了什么. 方法: ...

  9. git 命令详细介绍

    Git 命令详解 Git的基本命令: git pull:从其他的版本库(既可以是远程的也可以是本地的)将代码更新到本地,例如:'git pull origin master'就是将origin这个版本 ...

  10. LeetCode 804 Unique Morse Code Words 解题报告

    题目要求 International Morse Code defines a standard encoding where each letter is mapped to a series of ...