Yesterday review
Types of Python
Javapyhton
CPython
PyPy
Coding
! /usr/bin/env python
-*-coding:utf-8-*-
Print ("abc")
Name = Input ("name:")
Input interactive content is a string
Required numbers need to be defined with an int ()
While else
Break terminates the entire loop
Continue terminates when the second cycle enters the next cycle
Pycharm Installation Professional Edition
Don't be chinese.
Chinese can not use part of the function
Operator
In No in
Name = "Amanda"
If "mans" in Name:
Print ("yes")
Else
Print ("no")
If "man" isn't in name:
Print ("yes1")
Else
Print ("no1")
Boolean value:
True True
False false
Name = "Amanda"
v = ' mans ' in name
Print (v)
v2 = ' man ' isn't in name
Print (v2)
Comparison operation
==
>
<
>=
<=
! = does not equal (recommended)
<> Not equal to
Not
Not True = False
Not False = True
user = "Amanda"
PWD = "123"
v = user = = "Amanda" and pwd = = "123" or 1==1 and pwd = = "456"
Print (v)
No priority, run sequentially from left to right
v = (user = = "Amanda" and pwd = = "123") or (1==1 and pwd = = "456")
Print (v)
We recommend using parentheses to calculate the first
Arithmetic operations
+ Plus
+ Minus
* Multiply
/except
* * Power
% take-up
Take the whole
Assignment operations
Count = Count = 1
Count + = 1
Count = count-1
count-= 1
Count = Count * 1
Count *= 1
Count = COUNT/1
Count/= 1
Count = Count * * 1
Count **= 1
Count = count% 1
count%= 1
Count = Count//1
Count//= 1
Arithmetic operations and assignment operations are all real results.
The result of a comparison operation logical operation member operation is a Boolean value
#数据类型
Digital
A = 123
b = 456
String
A = "asdas"
b = "assfsd"
Boolean value
True True
False false
Digital
Python2 "shaping" "long shaping"
Python3 int
int ()
U = "123"
v = int (U)
Convert a string to a number
U2 = "a"
v2 = int (u2, BASE=16)
Converts a string into a number by 16
Age = 10
r = Age.bit_length ()
Calculate at least a few to represent the current number
String str
Test = "amAnda"
v = test.capitalize ()
Print (v)
Amanda First letter Capitalization
V1 = Test.casefold ()
Print (v1)
Amanda turns lowercase function many
V2 = Test.lower ()
Print (v2)
Amanda turns lowercase less function
V3 = Test.center (20, "*")
Print (v3)
amanda******* set the total length to center the content * One character fills the blank space in the default space
V4 = Test.count ("a")
Print (v4)
2 number of a in the string
V5 = Test.count ("a", 5)
Print (v5)
1 There are several aces starting with the fifth byte
V6 = Test.endswith ("da")
Print (v6)
True If the DA End is already
V7 = Test.startswith ("am")
Print (v7)
True whether to start with AM
Test = "amandaamanda"
v = test.find ("a")
Print (v)
2 start looking for an returned an in the first few from 0 did not find the return value-1
Test = "amandaamanda"
v = Test.index ("a")
2 start looking for an returned an in the first few from 0 did not find an error
Test = "I am {name}, age{age}"
v = Test.format (name= "Amanda", age= "21")
Print (v) formatting replaces placeholders in strings with established values
There is also a
Test = "I am {0}, age{1}"
v = Test.format ("Amanda", "21")
Replace by order
Dictionary formatting
Test = "I am {name}, age{age}"
v = test.format_map ({"name": ' Amanda ', "age": 21})
Test = "sdf123"
v = test.isalnum ()
Whether the print (v) string contains only numbers and letters
# Listing List
Ganso tuple
Dictionary Dict
boolean bool
Python Full Stack road "two" Foundation 2