Unicode String and method in Python
Unicode is a more extended form to include more functionally. As compare to 8-bit ASCII, while Unicode Strings stored as 16 bits with varied types of characters form many languages in the world. Generally, UNICODE is the superset of ASCII code. U is used as a prefix as same as raw String uses prefix r.
Example:
# Unicode program using symbol u
print (u'Hello, flocks')
#Output
Hello, flocks
Methods in python
1.capitalize()
# capitalize method convert first letter to upper case
txt1 = "what is your name."
s = txt.capitalize()
print (s)
2.casefold()
# casefold method the entire string to lower case
txt1 = "what Is Your Name."
s = txt.casefold()
print (s)
3.center()
# center method will place the string or character to the output screen
txt1 = "what is your name."
s = txt.center(20)
print (s)
4.count()
# count() count the value present in the string
txt1 = "what is your name."
s = txt.count(is)
print (s)
5.encode()
#encode method return the encrypted value provide by user
txt1 = "what is your name."
s = txt.encode()
print (s)
6.endswith()
# endswith method return boolean value when condition is true or false
txt1 = "what is your name"
s = txt.endswith(e)
print (s)
7.expandtabs()
# expandtabs set the tab space by default 8 spaces are fixed
txt1 = "what is your name."
s = txt.expandtabs(8)
print (s)
8.find()
#find method return the index value if find occurrence of value
txt1 = "Hello, here you will learn python"
x = txt.find("python")
print(x)
9.format()
#format method format the value provided inside function. where place placeholder is defined by {}
#named indexes:
str1 = "My name is {fname}, I'm {age}".format(fname = "Ravi", age = 26)
#numbered indexes:
str2 = "My name is {0}, I'm {1}".format("Ravi",36)
#empty placeholders:
str3 = "My name is {}, I'm {}".format("Ravi",36)
print(str1)
print(str2)
print(str3)
10.index()
#return the index value if string
str1 = "good afternoon"
w = str.index("good")
print(s)
