Python Learning Record and python record

Source: Internet
Author: User

Python Learning Record and python record
Terminal auto-completion. Note that you need to install the readline module> import OS> import rlcompleter, readline> readline, parse_and_bind ('tab: complete') to determine the data type (): Determine the Data Type isinstance (): Common operators used to determine the Data Type: +-*/% ** // <= and or not in Note: String concatenation, + The two sides must be of the same type if ...... else determines small = x if x <y: pass else: y while loop while condition: Loop Current for loop for target expression: loop current list = ['hello ', 'python'] 1. Add an element list to the list. append ('string')-> Add a single string list. extend (['string1', 'string2'])-> insert multiple inserted strings. The parameter is a list. insert (0, 'string3')-> specify the insert position 2. Delete the list element list. remove ('string')-> Delete the specified string del list [1]-> Delete the specified string list. pop ()-> Delete the last one by default. 3. view the list element list []-> View the index () content, note that the list [1:]-> View the content list [:] of the string whose index is 3-> View All content in the list 4. Two-Dimensional list: list5 = ['adb', ['M', 'D'], 'Hello'] list5 [1] [1] = 'D' 5. list of statistical elements. count ('string')-> count the number list. index ('string',)-> Start position statistics position where the first occurrence of 6, reverse element flip sorting menber. reverse () 7. sort (func, key, reverse = Flase) list. sort ()-> list from small to large. sort (reverse = True)-> from large to small 8. Copying elements list1 = list [:]-> is equivalent to copying data, list1 does not change list2 = list-> copy list is equivalent to renaming, list2 changes according to list

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.