string of python3.5

Source: Internet
Author: User

str1 = "GooGle"
STR2 = "Baidu"

#print ("Google's type is%s \ n"% type (str1)) #Google的类型是 <class ' str ' >
#print ("Google's method has%s"% dir (str1))

"""
Here's how a string object can be used
[' __add__ ', ' __class__ ', ' __contains__ ', ' __delattr__ ', ' __dir__ ', ' __doc__ ', ' __eq__ ',
' __format__ ', ' __ge__ ', ' __getattribute__ ', ' __getitem__ ', ' __getnewargs__ ', ' __gt__ ',
' __hash__ ', ' __init__ ', ' __iter__ ', ' __le__ ', ' __len__ ', ' __lt__ ', ' __mod__ ', ' __mul__ ',
' __ne__ ', ' __new__ ', ' __reduce__ ', ' __reduce_ex__ ', ' __repr__ ', ' __rmod__ ', ' __rmul__ ',
' __setattr__ ', ' __sizeof__ ', ' __str__ ', ' __subclasshook__ ', ' capitalize ', ' casefold ',
' Center ', ' count ', ' encode ', ' endswith ', ' expandtabs ', ' find ', ' format ', ' Format_map ',
' Index ', ' isalnum ', ' isalpha ', ' isdecimal ', ' isdigit ', ' isidentifier ', ' islower ',
' IsNumeric ', ' isprintable ', ' isspace ', ' istitle ', ' isupper ', ' join ', ' ljust ', ' lower ',
' Lstrip ', ' Maketrans ', ' partition ', ' replace ', ' rfind ', ' rindex ', ' rjust ', ' rpartition ',
' Rsplit ', ' Rstrip ', ' Split ', ' splitlines ', ' startswith ', ' strip ', ' swapcase ', ' title ',
' Translate ', ' upper ', ' Zfill ']
"""
#print (str1.__add__ (str2)) #Googlebaidu, concatenate two strings together to form a new string
#print (str1.__class__) #<class ' str ' >
#print (str1.__contains__ ("G")) #True whether it contains
#print (str1.__dir__ ())
#print ("%s initial capital%s"% (Str2,str2.capitalize ())) #baidu First Capital letter Baidu

#print (Str1.lower ()) #google, converts the string to lowercase, which is valid only for ASCII-encoded letters.
#print (Str1.casefold ()) #google, converts the string to lowercase, which in the Unicode encoding has the corresponding lowercase form.
# print (' ß '. lower ()) # ' ß ' is a German lowercase letter, it has another lowercase ' ss ', lower method cannot be converted
# print (' ß '. Casefold ()) # SS-German lowercase letter ß equivalent to lower case letter SS with uppercase SS

#print (Str1.center, "*")) #**google**, content in the specified width of the play, the other with * padding, the default blank.
#print (Str1.count ("E")) #1 the number of occurrences of a statistical substring in the original string, case-sensitive
#print (Str1.endswith ("E")) #True determine if str1 ends with E
#result = "Abcdgfgfgfgfgf\tlldf". Expandtabs () #将tab转换成空格, a tab is converted to 8 spaces by default
#print (Str1.find ("O")) # Find the position of the substring, if not found returns-1, case-sensitive
#print ("My name is {}". Format ("abc")) #my the name is ABC string formatting, dynamic parameters
The #print (Str1.index ("O")) # is similar to Str.find (), but if no substring is found, an error will be
#print ("[Email protected]". Isalnum ()) #判断是否是字母或数字, returns False if there are special symbols in the string that have letters and numbers
#print ("Af3". Isalpha ()) #判断字符串是否全部都是字母

#print ("123". Isdecimal ()) #如果字符串是只包含十进制字符返回True, otherwise returns false.
#print ("123". IsDigit ())
#print ("Class". Isidentifier ()) #判断字符串是不是关键字
#print ("abc". Islower ()) #判断字符串是否全部小写
"""
Three ways to go to a space
Print ("ABCD jlllll". Lstrip ()) #去掉字符串左边的空白字符,
Print ("ABCD 11223". Rstrip ()) #去掉字符串右边的空白字符
Print ("ABCD 112233". Strip ()) #去掉字符串两边的空白字符
"""
"""
Print ("[email protected] @jklfd". Partition ("@"))
With @ as the delimiter, if a delimiter is found, returns the part before the delimiter, the delimiter, and the part after the delimiter
If no delimiter is found, returns a string followed by two empty strings
"""
#print (Str1.replace ("O", "8", 1)) #用新字符串替换就字符串, replace all if the third parameter is not specified.

string of python3.5

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.