__author__ = 'mare' #STRING functions #capitalize() print( "PYTHON".capitalize() ) #Python print( "Python is powerful".capitalize() ) #Python is powerful #count(keyword, [start, [end]]) print( "python is powerful".count('p') ) print( "python is powerful".count('p', 5) ) #[5:] print( "python is powerful".count('p', 0, -1) ) #[0:-1] #2 #1 #2 #encode([encoding, [errors]]) print( "๊ฐ๋๋ค".encode('cp949') ) print( "๊ฐ๋๋ค".encode('utf-8') ) #b'\xb0\xa1\xb3\xaa\xb4\xd9' #b'\xea\xb0\x80\xeb\x82\x98\xeb\x8b\xa4' #endswith(postfix, [start, [end]]) print( "python is powerful".endswith('ful')) print( "python is powerful".endswith('ful', 5)) print( "python is powerful".endswith('ful', 5, -1)) #True #True #False print( "python is powerful".endswith(('m', 'l')) ) #True #expandtabs([tabsize]) print( "python\tis\tpowerful".expandtabs() ) print( "python\tis\tpowerful".expandtabs(1) ) #python is powerful #python is powerful #find(keyword, [start, [end]]) print( "python is powerful".find('p') ) print( "python is powerful".find('p', 5, -1) ) print( "python is powerful".find('pa') ) #0 #10 #-1 #index(keyword, [start, [end]]) print( "python is powerful".index('p') ) print( "python is powerful".index('p', 5, -1) ) #0 #10 #print( "python is powerful".index('pa') ) #Traceback (most recent call last): #File "/Users/mare/PycharmProjects/str_handling/str_handle.py", line 58, in#print( "python is powerful".index('pa') ) #ValueError: substring not found #isalnum() print( "python".isalnum() ) print( "python3000".isalnum() ) print( "python3.2".isalnum() ) #True #True #False #isalpha() print( "python".isalpha() ) print( "python3000".isalpha() ) #True #False #islower() print( "python".islower() ) print( "Python".islower() ) print( "python3.2".islower() ) #True #False #True #isspace() space, tab, change line... is ture print( " ".isspace() ) print( "\t\n".isspace() ) print( "\thi\n".isspace() ) #True #True #False #istitle() print( "python is powerful".istitle() ) print( "PYTHON IS POWERFUL".istitle() ) print( "Python Is Powerful".istitle() ) #False #False #True #isupper() print("python".isupper()) print("PYTHON".isupper()) print("PYTHON3.2".isupper()) #False #True #True #isdecimal(), isdigit() print( "2580".isdecimal() ) #True #isnumeric() print( '\u00bc'.isdecimal() ) print( '\u00bc'.isnumeric() ) #False #True print("id_1".isidentifier()) print("1_id".isidentifier()) #True #False #isprintable() print("test".isprintable() ) print( '\u0014'.isprintable() ) #True #False #join(sequence) print(".".join("HOT")) print("\t".join(["python","is","powerful"])) #H.O.T #python is powerful #lstrip([chars]) print( "\t python".lstrip()) print( ">>> python is powerful".lstrip("> ")) #python #python is powerful #maketrans(x, [y, [z]]) transmap = str.maketrans( {"p":"P"} ) print( "python is powerful".translate(transmap) ) #Python is Powerful transmap = str.maketrans( "poieu", "P0129" ) print( "python is powerful".translate(transmap) ) #Pyth0n 1s P0w2rf9l transmap = str.maketrans( "p", "P", "!" ) print( "python is powerful!!!".translate(transmap) ) #Python is Powerful #partition(separator) print( "python is powerful".partition("is") ) #('python ', 'is', ' powerful') #replace(old, new, [count]) print( "python is powerful".replace("p", "P")) print( "python is powerful".replace("p", "P", 1)) #Python is Powerful #Python is powerful #rfind(keyword, [start, [end]]) print( "python is powerful".rfind('p')) print( "python is powerful".rfind('p', 0, 9)) print( "python is powerful".rfind('pa')) #10 #0 #-1 #rindex(keyword, [start, [end]]) print( "python is powerful".rindex('p')) #10 #rpartition(separator) print( "python is powerful".rsplit()) print( "python is powerful".rsplit(' ',1)) #['python', 'is', 'powerful'] #['python is', 'powerful'] #rsplit([separator, [maxsplit]]) print( "python is powerful".rsplit() ) print( "python is powerful".rsplit(' ',1) ) #['python', 'is', 'powerful'] #['python is', 'powerful'] #rstrip([chars]) print( "python \t".rstrip() ) #python #split([separator, [maxsplit]]) print("python is powerful".split() ) print("python is powerful".split(' ', 1)) #['python', 'is', 'powerful'] #['python', 'is powerful'] #splitlines([keep]) print( "python\r\nis\npowerful".splitlines() ) #['python', 'is', 'powerful'] #startswith(prefix, [start, [end]]) print( "python is powerful".startswith('py')) print( "python is powerful".startswith('py', 5)) print( "python is powerful".startswith('py', 0, 5)) print( "python is powerful".startswith(('p', 'm'))) #False #True #True #strip([chars]) print( "\t python \t".strip() ) print( ">>> python <<<".strip("<> ") ) #python #python #swapcase() print("Python3.2".swapcase() ) #pYTHON3.2 #title() print( "python is powerful".title() ) #Python Is Powerful #upper() print(" Python3.2".upper() ) #PYTHON3.2
2/24/2014
(python study) string functions
Subscribe to:
Post Comments (Atom)
-
As you can see in the following video, I created a class that stitching n cameras in real time. https://www.youtube.com/user/feelmare/sear...
-
Image size of origin is 320*240. Processing time is 30.96 second took. The result of stitching The resul...
-
The MNIST dataset is a dataset of handwritten digits, comprising 60 000 training examples and 10 000 test examples. The dataset can be downl...
-
Background subtractor example souce code. OpenCV support about 3 types subtraction algorithm. Those are MOG, MOG2, GMG algorithms. Det...
-
In past, I wrote an articel about YUV 444, 422, 411 introduction and yuv rgb converting example code. refer to this page -> http://feel...
-
In the YUV color format, Y is bright information, U is blue color area, V is red color area. Show the below picture. The picture is u-v col...
-
This is data acquisition source code of LMS511(SICK co.) Source code is made by MFC(vs 2008). The sensor is communicated by TCP/IP. ...
-
* Introduction - The solution shows panorama image from multi images. The panorama images is processing by real-time stitching algorithm...
-
This article explain how to access the thread index when you make block and thread with two dimensions. please refer to this page about me...
-
GetMacAddress in MFC Get by using GetAdaptersInfo function // .. Get by using ip address //If localhost -> GetMacAddress(_T(...
No comments:
Post a Comment