1. String formatted output
% Placeholders:
% S - Canton declared string type placeholder% d% i-- escaped become common integer %%%
%s ,%d, %%
msg = '%s,学习进度5%%'
print(msg%(input("name:")))
%s -- 占字符串的位置
%d -- 占整型的位置
%% -- 转义(把占位转换成普通的%号)
name = input("name")
print(f"alex{name},{'aaa'}")
% () No more, no less, correspondence
name = input("name:")
age = input("age:")
sex = input("sex:")
job = input("job:")
hobby = input("hobby:")
print(msg%(input("name:"),input("age:"),input("sex:"),input("job:"),input("hobby:)
f "{}" braces are generally placed inside the content string variable in single quotes
3.6 or later is required to use
2.while cycle
while key conditions: (infinite loop)
Loop
Conditions Terminator Cycle
break terminates the current cycle
continue out of this cycle, the next cycle continues
3. Operator
Arithmetic operators:
Contains + - * / ** //%
Assignment operator:
= += -= *= **= %= //=
Logical operators:
and (with - and) or (or) not (non - not)
1 and 0 # and是两边都是真的时候才是真,只要有一边是假就取假
0 and 1
print(1 and 9) #and 运算 两边都是真的时候取and后边的内容
print(False and 0) #and 运算 两边都是假的时候取and前边的内容
Comparison Operators
== != > < >= <=
Member operator
in the absence not in
4. encoding
ASCII code - the first computer code is not supported by Chinese
GBK-- GB:
English one byte
Chinese 2 bytes
Unicode- Unicode:
English 2 bytes
Chinese 4 bytes
utf-8- most popular encoding
English byte
Owen 2 bytes
Asian 3 bytes
Unit conversion:
1B=8b
1024B=1KB
1024KB=1MB
1024MB=1GB
1024GB=1TB