Learning record 2
1. Data Type
(1) The digital shaping --int
(2) a string --str
(3) A Boolean value --bool Only True and False
(4) List --list
(5) Ganso --tuple
(6) dictionary --dict
(7) other
type () to view the type of data in parentheses, following codes are output as <class 'int'>
b=452 v=type(b) print(v)
int () converts the data to integer number, the result is 10 and the following code 3
= NUM ( ' a ' ) V = int (NUM, Base = 16) # to convert a character in hexadecimal to decimal method Print (V) num2 = ( ' 0011 ' ) V1 = int (num2, Base = 2 ) Print ((v1))
2. Operator
(1) logical operators
and and
or 或
not non
No priority operation, when the press before and after the order of operations without parentheses. example:
v=1==1 and 1+2==3 or 1+1==3 print(v)
Ture results
(2) Comparison operators
(3) member operator
= name ' Lee phase He ' V = " Lee phase " in name Print (V) # output to true, the description "Lee phase" sequence "Lee phase hertz", also known substring
(4) arithmetic operators
Previous've got
(5) assignment operator
(6) to be supplemented Bitwise Operators
(7) the identity operator
3. Methods
(1)bit_length()
The reaction corresponding to the current number of binary digits
age=18 r=age.bit_length() print(r)
5 results
(2)capitalize()
The first letter capitalized string
(3)title()
String each word capitalized
(4) upper () and lower ()
All letters big \ lowercase, casefold () and lower the same, but a wider range (special characters)
(5)center(self,width,fillchar=None)
name='MC' r=name.center(20,'*') print(r)
The output is ********* MC *********
(6)endswith\startswith(self, suffix, start=None, end=None)
Determine whether the beginning of a string
v='name'.endswith('m',2,3) print(v)
Output is True
(7)