__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)
-
Logistic Classifier The logistic classifier is similar to equation of the plane. W is weight vector, X is input vector and y is output...
-
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...
-
fig 1. Left: set 4 points (Left Top, Right Top, Right Bottom, Left Bottom), right:warped image to (0,0) (300,0), (300,300), (0,300) Fi...
-
Image size of origin is 320*240. Processing time is 30.96 second took. The result of stitching The resul...
-
* Introduction - The solution shows panorama image from multi images. The panorama images is processing by real-time stitching algorithm...
-
Created Date : 2011.10 Language : C/C++ Tool : Microsoft Visual C++ 2008 Library & Utilized : OpenCV 2.3 Reference : SIFT referenc...
-
OpenCV has AdaBoost algorithm function. And gpu version also is provided. For using detection, we prepare the trained xml file. Although...
-
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...
-
simply check below code and example result. . def image_grid ( imgs , rows , cols ): assert len ( imgs ) == rows * cols w , h...
-
I once wrote the following article. http://study.marearts.com/2014/04/opencv-study-mat-point-access-method.html This article is a sample c...
No comments:
Post a Comment