The concatenation method of string
(a) direct use of "+" sign, low efficiency (will open up another space in memory)
name = ' Jacky ' + ' Zhao '
(ii) string formatting
Name = '%s%s '% (' Jacky ', ' Zhao ')
(iii) Join method
ListName = [' Jacky ', ' Zhao ']name = '. Join (ListName)
Two ways to create a list
#方式一a = [' A ', ' B ', ' 1 ', ' 2 '] #方式二a = List (' A ', ' B ', ' 1 ', ' 2 ')
List operation methods:
Indexed index
Slice:
Append Append
Length Len
Delete del, remove, pop
Loop for, while
(Interrupt loop) Break: Terminates the current loop
Continue: Terminating the secondary cycle
Pass: Placeholder (grammar check)
return: Function termination
Exit: Exit the program
Contains in, _contains_
Ganso's Modification:
Ganso elements are not modifiable
A = (1,2,3,4)
Del A[0]
Traceback (most recent):
File "<pyshell#38>", line 1, in <module>
Del A[0]
TypeError: ' Tuple ' object doesn ' t support item deletion
Elements of the Ganso element can be modified
A = (1,2,3,{' A ': ' B '}) (a[3][' a '] = ' C ') print (a) (1,2,3,{' A ': ' C '})
Python Basic data type