Python in float and long inside function and string str introduction

Source: Internet
Author: User

1 Float Type2As_integer_ratio#convert decimals to the simplest ratio3 columns such as40.5 converted to 1/2, cannot convert 2/4, because it is the simplest than5 other and long types are the same as int types6 7 no matter which voice is basically a string and set of operations, learning, you can learn the collection and the use of strings, columns such as Python collection, lists, dictionaries, tuples, etc.8 9 operation of the STR string, focusing onTen Type , view types, objects are created by that class One columns such as: A type (name) - dir looks at all the methods in the class and provides which members can use the - columns such as the dir (name) - __contains__            #contains, determines whether a file exists, as in function, contains a return true, does not contain return false - columns such as: -Aa='QQQQQ' +Result-=aa.__contains__(QQ)#equals result= ' QQ ' in name - __eq__                        #equality of strings, equals = = + __getattribute__        #It will be used when reflected. A __getitem__                 at  -Capitalize ()#Capitalize first letter - columns such as: -A=' AAA ' -result=a.capitalize () - Print(AA) inAaa#Results -  toCasefold ()#capitalize the first letter to lowercase, similar to the capitalize above + columns such as: -A=' Aaa ' theresult=a.capitalize () * Print(AA) $Aaa#ResultsPanax Notoginseng   -Center#Center display, default space padding the columns such as +A=' AAA ' AResult=a.center (20,'*')#20 indicates an empty number of digits, * denotes a filled character, default is a space, the Print(Result) +aaa**********#Results
 $  Count # Counts the number of occurrences of a             string, and you can also specify the range that appears,  such as:
 -  Specify the range, the back of a will not go to find, only in 0-10.
 -  Encode            # Conversion code in 3, the parentheses understand the encoding format  as:
 -  EndsWith            # The character is determined by what end, the parentheses fill in the character and range to be judged, do not specify a range default is all, is return true, not return false    Columns such as:
 About Specify range
 expandtabs                # for converting to spaces, the default one expandtabs to 8 spaces, you can specify
\ t # means tab, a TAB key, tab is commonly used when writing a configuration file, and you can use Expandtabs to convert \ t to spaces when reading with Python
 # Find    # go to a string to find the position of a character, find the location of the index to return it, also support the specified range, if the found character does not exist return-1 columns such as:
 the  The index        # is the same as find, but if the character you are looking for does not exist, you will get a direct error
 the when not present
   format #   string concatenation, same as% and plus sign   " name= "," AA {0} " KK {1} lll {2} ' #   starting from 0   74  result=name.format ("   AA   ", "   GGGG   ", "   VVVV   ") #   The content here should correspond to the previous index number 
75 print (Result)
 the You can also replace the variable with the same effect  + columns such as:
 the Join # used to do stitching, the list, the elements inside the tuple together, the default is an empty connection, you can specify the link of the bayi column, such as: There is a connector for the specified
       ljust #   Fu left, as with center center, preceded by the number specified for its total width  g  Rjust #   Word Fu right, ibid.    style= "color: #000000" and columns such as:   
       lower #   Turn the letter into lowercase   *  lstrip #  Remove the left space   "" "" "Maketrans #   do the corresponding table substitution, and then replace it, not often   90  partition #   character split, in parentheses you can specify a delimiter       
 the Replace # substitution, padding in parentheses (original character, new character, number of substitutions), then it will replace all of that word nonalphanumeric with 94 column such as: Replace 2 A for Q
 theSplit#Specify character split string the back with Rsplit and so on with the front function, but from right to left98Splitlines#Split as a behavior, as with the split (' \ n ') function AboutStartsWith#to begin with, to correspond with EndsWith -Strip#Remove a character101Swapcase#case to convert, convert all uppercase to lowercase, or lowercase to uppercase102Title#title, after use, it will turn all the first of the string into uppercase103Upper#. Lowercase to uppercase

Python in float and long inside function and string str introduction

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.