__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)
-
Image size of origin is 320*240. Processing time is 30.96 second took. The result of stitching The resul...
-
Background subtractor example souce code. OpenCV support about 3 types subtraction algorithm. Those are MOG, MOG2, GMG algorithms. Det...
-
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. ...
-
Logistic Classifier The logistic classifier is similar to equation of the plane. W is weight vector, X is input vector and y is output...
-
The MNIST dataset is a dataset of handwritten digits, comprising 60 000 training examples and 10 000 test examples. The dataset can be downl...
-
Google Coral USB Edge TPU Implementation Guide 1. Installation and Troubleshooting 1.1 Hardware Requirements Google Coral USB Accelerator ...
-
I use MOG2 algorithm to background subtraction. The process is resize to small for more fast processing to blur for avoid noise affectio...
-
RTSP(Real Time Streaming Protocol) is video streaming, it usually sent from network camera. VideoCapture function in opencv also can get r...
-
Created Date : 2011.2 Language : C/C++ Tool : Microsoft Visual C++ 2010 Library & Utilized : OpenCV 2.2 Reference : Interent Refer...
-
Video stabilization example source code. The principle is like that... Firstly, to obtain 2 adjacent images extract good feature to t...
No comments:
Post a Comment