1. The format of the output string
- % :Placeholder
- % S: string
- And% d% i: Integer
- %%: Escape become common%
- % (): Number of data inside the brackets no more and no less, must correspond
- f "{} '': the contents of the braces are generally put variable, if you want to put a string, you need to use single quotes # Python3.6 and above to use this feature
2. while loop
while keyword criteria: infinite loop #
Loop
Conditions Terminator Cycle
- break: terminate the current cycle
- continue: out of this cycle, the next cycle continues
- exit (0): terminates the current program
3. Operator
Arithmetic Operators
+ - * / # 加减乘除 ** #幂 print(2 ** 4) // #整除 print(5 // 2) % #取余(模) print(5 % 2)
Assignment Operators
a = 1 a += 1 # a = a + 1 a -= 1 # a = a - 1 a *= 1 # a = a * 1 a /= 1 # a = a / 1 a **= 1 # a = a ** 1 a %= 1 # a = a % 1
Logical Operators
and (与) #和 or (或) not (非) # 不是 1 and 0 # and是两边都是真的时候才是真,只要有一边是假就取假 0 and 1 print(1 and 9) #and 运算 两边都是真的时候取and后边的内容 print(False and 0) #and 运算 两边都是假的时候取and前边的内容 print(3 > 2 and 9) #3>2 视为一个整体来看 print(1 or 0) # 只要有一个是真就取真 print(0 or 1) print(1 or 4) # or 两个都是真的时候,取or前面的内容 print(False or 0) # or 两个都是假的时候,取or后面的内容
Comparison Operators
等于 == 不等于 != 大于 > 小于 < 大于等于 >= 小于等于 <=
Member operator
is 是 is not 不是 is 判断是不是同一个 == 判断是不是长得一样
4. encoding
ASCII code: does not support Chinese
GBK: GB
- English one byte
- Chinese 2 bytes
Unicode: Unicode
- English 2 bytes
- 4 Chinese characters
utf-8: Unicode-based, it is now the most popular encoding, with at least one byte
- English one character
- European two characters
- Asian 3 characters
utf-16: with a minimum of 2 bytes
Unit Conversion
1 byte = 8 # most important
1Byte = 8bit
1024KB = 1MB
...