Int integer
Calculation and comparison
a.bit_length () # required number of decimal digits when converted to a binary occupied
Boolean value bool
True False True False
Digital converted into Boolean values: 0 False non 0 True
String into a Boolean value: empty string "" False True non-empty
Converted into a digital Boolean True = 1 False = 0
Boolean value into a string True = str (True) False = str (False)
String str
Role: store small amounts of data
Index (subscript): from left to right 0, 1, 2, 3 from right to left ;;;; -1, -2, -3, -4
(Out of range will complain when searching)
Slice: [Start position: is terminated] regardless of the end time is out of range to find the right care
Step: Find direction decision determines the look of the step size defaults to 1 by default direction from left to right
---- neuron progenitor list of strings are indexed [index]
The index is an accurate positioning element
Support indexing of support sections [index]
Slicing length may be out of range index length can not exceed the range [start position: is terminated: step]
Step: determine the direction to go, we decided to take the big steps
commonly used ways
ALL CAPS upper
All lowercase lower
What to begin with startswith
To what end endswith
Go trailing spaces (default remove and remove line breaks) strip
The default split is separated by spaces, you can specify your own split
Replace replace ( "old" and "new")
Statistical statistics count the number of times a certain content appears
String formatting format () in three ways
s12 = "My name is {}, {} years old this year, and I like {}". format ( "Jay", 28, "Chow Yun Fat") # by location format print (s12)
s12 = "My name is {0}, {2} years old this year up, and I like to {1}". format ( "Jay", "Chow Yun Fat", 28) # specified location
s12 = "My name is {name}, this year {age} years old, and I like {singer}". format (name = "Jay", singer = "Chow Yun Fat", age = 28) # keyword print (s12 )
is:
isdecimal () determines whether a decimal
isalnum judgment is not Chinese, letters, numbers
isalpha judgment is not Chinese, the letters
for loop
for i in xxx:
i variable for keywords in the keyword xxx iterable (can not use int or bool)
After the loop variable i points to the last element
Placeholders: pass or ...
range
python3 print range is in itself
python2 is a list of print
range (the starting position, until the termination step) is connected to a comma
range (10) ---- range () terminates the start position 0 up to 10
Simple built-in functions
upper () converted to uppercase. Ignore case when
strip () to remove the right and left ends blank user input content must go blank
replace (old, new) string replacement
split () cutting result list
Whether startsWith () is determined at the beginning xxx
find () to find
isdigit () determines whether the numbers
len () function --- plant length required data type "int bool" can not be used