String of python3.5, python3.5string

Source: Internet
Author: User

String of python3.5, python3.5string

Str1 = "GooGle"
Str2 = "baidu"

# Print ("Google type is % s \ n" % type (str1) # Google type is <class 'str'>
# Print ("Google methods include % s" % dir (str1 ))

"""
The following describes how to use string objects.
['_ Add _', '_ class _', '_ ins INS _', '_ delattr __', '_ dir _', '_ doc _', '_ eq __',
'_ Format _', '_ ge _', '_ getattribute _', '_ getitem _', '_ getnewargs __', '_ gt __',
'_ Hash _', '_ init _', '_ iter _', '_ le _', '_ len __', '_ lt _', '_ mod _', '_ mul __',
'_ Ne _', '_ new _', '_ reduce _', '_ performance_ex _', '_ repr __', '_ rmod _', '_ rmul __',
'_ Setattr _', '_ sizeof _', '_ str _', '_ subclasshook _', 'capitalize', 'casefold ',
'Center', 'Count', 'encoding', 'enableswith', 'pandtabs ', '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', 'regionust', 'rpartition ',
'Rsplit ', 'rdstrip', 'split', 'splitlines ', 'startswith', 'strip', 'swapcase', 'title ',
'Translate', 'uppper ', 'zfill']
"""
# Print (str1. _ add _ (str2) # Googlebaidu connects two strings to form a new string
# Print (str1. _ class _) # <class 'str'>
# Print (str1. _ contains _ ("g") # Whether True contains
# Print (str1. _ dir __())
# Print ("% s capitalized % s" % (str2, str2.capitalize () # baidu capitalized Baidu

# Print (str1.lower () # google converts a string to lowercase, which is only valid for ASCII-encoded letters.
# Print (str1.casefold () # google converts a string to a lower-case string. In Unicode encoding, all strings in the corresponding lower-case format are converted.
# Print ('lower '. lower () # 'lower' is a lower-case German letter with another lower-case 'ss'. The lower method cannot be converted.
# Print ('signature'. casefold () # ss lowercase letters in German are equivalent to lowercase letters in ss, whose uppercase is SS

# Print (str1.center (10, "*") # ** GooGle **. The content is in the specified width. Fill the content with *. The content is blank by default.
# Print (str1.count ("e") #1 count the number of times the substring appears in the original string, case sensitive
# Print (str1.endswith ("e") # True determines whether str1 ends with e
# Result = "abcdgfgfgfgfgfgf \ tlldf". expandtabs () # convert a tab to a space. By default, one tab is converted to eight spaces.
# Print (str1.find ("o") # locate the substring. If-1 is not found, it is case sensitive.
# Print ("my name is {}". format ("abc") # my name is abc string formatting, dynamic parameter
# Print (str1.index ("o") # similar to str. find (), but if no substring is found, an error is returned.
# Print ("abjhjd323 @". isalnum () # determine whether it is a letter or number. If the string contains a special character or number, false is returned.
# Print ("af3". isalpha () # determine whether all strings are letters

# Print ("123". isdecimal () # If the string contains only decimal characters, True is returned; otherwise, False is returned.
# Print ("123". isdigit ())
# Print ("class". isidentifier () # determine whether a string is a keyword
# Print ("abc". islower () # determine whether all strings are in lowercase.
"""
Three methods for removing Spaces
Print ("abcd jlllll". lstrip () # Remove the white space on the left of the string,
Print ("abcd 11223". rstrip () # Remove the white space on the right of the string
Print ("abcd 112233". strip () # Remove the white spaces on both sides of the string
"""
"""
Print ("abc @ 123 @ jklfd". partition ("@"))
Use @ as the separator. If the separator is found, the part before the separator, the separator and the part after the separator are returned.
If no separator is found, the return string and two empty strings
"""
# Print (str1.replace ("o", "8", 1) # Replace the string with the new string. If the third parameter is not specified, replace all.

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.