Python strings Function

String assignment using ' or ":

>>> s = 'Perschon.com'
>>> s2 = "Perschon.com"
>>> s == s2
True
String is can be treated as a list of characters:
>>> s[0]
'E'
>>> s[3:6]
'Mem'
Search for substring:
>>> x = 'Perschon Python Tutorial'
>>> 'P' in x
True
>>> 'x' not in x
True
String concatenation use "+", "+=" operators or join() Method.
>>> str = "python"
>>> str += " tutorial"
>>> str
"python tutorial"
>>> str2 = "Perschon"
>>> str3 = " -- ".join((str,str2))
>>> str3
"python tutorial -- Perschon"

>>> str = "python"
>>> str2 = " tutorial"
>>> str3 = str + " " + str2
>>> str3
'python tutorial'
split() method divide a string based on specified separator.
>>> x = 'Perschon Python Tutorial'
>>> x.split('th')
['Perschon Py', 'on Tutorial']
>>> x.split('o')
['EndMem', ' Pyth', 'n Tut', 'rial']
>>> x.split('o',1)
['EndMem', ' Python Tutorial']
String formatting for print:
>>> print ("%s is No. %d" % ("perschon.com", 1))
perschon.com is No. 1
Python string format symbol list:

Symbol
Description
%c
character
%s
string
%d
signed decimal integer
%i
integer
%u
unsigned decimal integer
%o
octal integer
%f
floating number
%e
exponential notation with lowercase e
%E
exponential notation with uppercase E
%x
hexadecimal integer in lowercase
%X
hexadecimal integer in uppercase