Python String字串操作

2022-09-07 13:21:12 字數 1774 閱讀 5410

1 name='

xioer-pipo'2

3print(name.capitalize()) #

第乙個字元大寫

4print

(name.expandtabs())

5print(name.count('

o')) #

統計重複資料

6print(name.endswith('

}')) #

最後是否為這個字元

7print(name[name.find('

mong

'):8]) #切片8

print(name.format(name='

alex

',year='

23')) #

格式化輸出

9print(name.format_map()) #

格式化輸出

10print('

ab123

'.isalnum()) #

包含數字和英文本元

11print('

we'.isalpha()) #

純英文本元

12print('

100'.isdecimal()) #

是不是十進位制數字

13print('

100'.isdigit()) #

是不是乙個數字

14print('

opp'.isidentifier()) #

判斷是不是乙個合法的識別符號(合法的變數名)

15print('

1ea'.islower()) #

是否小寫

16print('

my name is

'.isupper()) #

是不是大寫

17print('

'.isspace()) #

是不是空格

18print('

my name is

'.istitle()) #

是不不title

19print('

my name is

'.isprintable()) #

用處 tty file drive

20print('

,'.join(['

1','

2','

3'])) #

列印列表,有逗號隔開

21print(name.ljust(50,'*'

))22

print(name.rjust(50,'-'

))23

print('

kong

'.lower()) #

大寫轉小寫

24print('

kong

'.upper()) #

小寫轉大寫

25print('

\n kong\n

'.strip()) #

去除空格、換行

26print('

ming

'.replace('

e','

e',1))

27print('

ming-dd-ff

'.split('

-')) #

以指定符號分割字元,生成列表

28print('

ming dd ff

'.swapcase()) #

大寫變小寫,小寫變大寫

29print('

ming dd ff

'.title())

Python String字串操作

1 name xioer pipo 2 3print name.capitalize 第乙個字元大寫 4print name.expandtabs 5print name.count o 統計重複資料 6print name.endswith 最後是否為這個字元 7print name name.f...

ORACLE in 字串,字串,字串

因為傳進來的引數是 字串,字串,字串,要實現in 字串,字串,字串 select from htl price p where p.hotel id 30073328 and p.able sale date between to date 2009 03 27 yyyy mm dd and to ...

字串,字串陣列,字串指標!!

字串 字元陣列實際上是一系列字元的集合,也就是 字串 string 字串陣列 在c語言中,沒有專門的字串變數,沒有string型別,通常就用乙個字元陣列來存放乙個字串。c語言規定,可以將字串直接賦值給字元陣列 在c語言中,字串總是以 0 作為串的結束符。上面的兩個字串,編譯器已經在末尾自動新增了 0...