Day 2 python learning Notes

1, the list

  1.1 List of elements in square brackets [] enclosed, with commas between elements, separated

  1.2 the list elements may be of different types

  1.3 Access list element format is: list name [index]

  1.4 In situ support change

2, the dictionary table

  2.1 with a dictionary table elements enclosed in braces {}, with commas between elements, separated

  2.2 dictionary table of elements is a bond, value pairs

  2.3 accessible format dictionary table element is: name dictionary [key], name or dictionaries .get (key)

3, tuples

  3.1 yuan group of elements in parentheses () enclosed, with commas between elements, separated

  Access 3.2 format element tuple: tuple name [index]

  3.3 does not support in-situ change

4, the division value

  With 4.1 /, //, // which removes the fractional part

5, print function

  5.1 comes with Stop Sign \ n

  5.2 custom symbol terminates, end = ''

6、isinstance()

  Determining whether an element of a certain type, such as isinstance (3, int)

7, access the string elements

  7.1 access individual elements: name [index]

  7.2 multiple access elements: a string name [index: index]

  7.3 Access end elements: Name String [-1], or string name [len () - 1]

  7.4 Take some elements: string name [:: 2]

  7.5 taking all the elements: string name [:]

8, a list of character string conversion

  8.1 String transfer list: list (string)

  8.2 to String list:. '' Join (list)

9, python exchange variables

  a,b=b,a

10, list comprehension

  [C ** 2 for c in the list]

11, copy the list of questions that need attention

  11.1 a = [1,2,3], b = a, the changes to be made will be reflected to a b which

  11.2 a = [1,2,3], b = a [:], for a change is made will not affect b

  11.3 a = [1,2,3], b = a.copy (), a change is made to not affect b

Guess you like

Origin www.cnblogs.com/zhuome/p/11294381.html
Recommended