String of python3.5, python3.5string

Source: Internet
Author: User

String of python3.5, python3.5string

At the beginning, I learned how to use python. This is barely the first blog. It mainly records the methods in the string, which are not accurate or incorrect, please advise str1 = "GooGle" str2 = "baidu" # print ("the Google type is % s \ n" % type (str1 )) # The Google type is <class 'str'> # print ("Google methods include % s" % dir (str1 )) "The following describes the methods available for string objects: ['_ add _', '_ class _', '_ contains __', '_ delattr _', '_ dir _', '_ doc _', '_ eq _', '_ format __', '_ ge _', '_ getattribute _', '_ getitem _', '_ getnewargs _', '_ gt __', '_ hash _', '_ in It _ ',' _ iter _ ',' _ le _ ',' _ len _ ',' _ lt __', '_ mod _', '_ mul _', '_ ne _', '_ new _', '_ reduce __', '_ performance_ex _', '_ repr _', '_ rmod _', '_ rmul _', '_ setattr __', '_ sizeof _', '_ str _', '_ subclasshook _', 'capitalize', 'casefold', 'center', 'Count ', 'enabled', 'enabledwith', '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', 'effectust', 'rpartition', 'rsplit ', 'rdstrip', 'split ', 'splitlines ', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'uppper ', 'zfill'] "# print (str1. _ add _ (str2) # Googlebaidu, connect the two strings, create a new string # print (str1. _ class _) # <class 'str'> # Print (str1. _ contains _ ("g") # Whether True contains # print (str1. _ dir __()) # print ("% s uppercase % s" % (str2, str2.capitalize () # baidu uppercase Baidu # print (str1.lower () # google, converts a string to lowercase letters, which are only valid for ASCII characters. # 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 ('signature '. lower () # 'taobao' is a lower-case German letter with another lower-case 'ss'. The lower method cannot be converted # print ('taobao '. casefold () # ss lowercase English letters (ss): SS # print (str1.center (10, "*") # ** GooGle **, content is in the specified width. For other content, fill it with *. The default value is blank. # Print (str1.count ("e") #1 count the number of times the substring appears in the original string, case sensitive # print (str1.endswith ("e ")) # True: judge whether str1 ends with e # result = "abcdgfgfgfgfgf \ tlldf ". expandtabs () # convert a tab to a space. By default, a 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 format, dynamic parameter # print (str1.index ("o") # similar to str. find (), but if no substring is found, an error is reported # print ("abjhjd323 @". isalnum () # determines whether it is a letter or number. If the string contains letters or numbers Special symbol. false # print ("af3") is returned ". isalpha () # determine if all strings are letters # print ("123 ". isdecimal () # returns True if the string contains only decimal characters; otherwise, returns False. # Print ("123 ". isdigit () # print ("class ". isidentifier () # determine if the string is a keyword # print ("abc ". islower () # determine whether all strings are in lowercase. "" print ("abcd jlllll ". lstrip () # Remove the white space on the left of the string, print ("abcd 11223 ". rstrip () # Remove the white space print ("abcd 112233") on the right of the string ". strip () # Remove the blank characters "print (" abc @ 123 @ jklfd ". partition ("@") uses @ as the separator. If the separator is found, the part before the separator is returned. If the separator is not found, returns the 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.