python学习基础内容博客:https://www.cnblogs.com/alex3714/articles/5465198.html
--------------------------
下面为知识点总结:
*.pyc文件的存在,Python是一门先编译后解释的语言
注释:
""" 多行注释 """
#单行注释
关键字
['and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'exec', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'not', 'or', 'pass', 'print', 'raise', 'return', 'try', 'while', 'with', 'yield']
用户输入格式:
input("输入内容") ---名文输入
getpass.getpass("输入内容") ---密文输入
**默认输入格式为字符串 --- 强制转换: int( ) ---格式:类型()
引用:
name=test
info1=''' {NAME}'''.format(NAME=name)
info2='''%s''' % (name)
info3='''{0}'''.format(name) ---一种特殊的引用
判断:
参数:and or != ; == | =
(1):
if 1==1:
print("OK")
else:
print("NO")
(2):
if :
print("OK")
elif:
print("OK")
else:
print("OK")
循环:
参数: break, True, False ,continue
判断:
range(开始,结尾,步长)
(1):
while 条件:
内容
else:
正常走完while就执行
(2)
for i in 判断
内容
else:
正常走完for就执行
数据类型:
int:Python会自动将整数数据转换为长整数
long:位数比int多
float:有小数
complex:工程领域
bytes:python3特有,区分了string和bytes,string(decode)<-->bytes(encode)
"字符".encode(encoding="要转换的字符类型")
变量名.encode(encoding="要转换的字符类型")
例如:msg.encode(encoding="utf-8").decode(encoding="GB2312")
bool:
0:False
1:True
运算:
与:1与任何数都得1 --- 或0与任何数都得0
数字运算:+,-,*,/,%,**,//
比较运算:==,!=,<>,<,>,>=,<=
赋值运算:=,+=,-=,*=,/=,%=,**=,//=
逻辑运算:and ,or ,not
成员运算:in, not in
身份运算:is, is not
位运算:&,|,^(相同为0,不同为1),~,<<,>>
运算符的优先:
** ~,+,- *,/,%,// +,- >>,<< & ^,| <=,<,>,>= <>,==,!= =,%=,/=,//=,-=,+=,*=,**= is,isnot in,notin not,or,and
三元运算:
result = 值1 if 条件 else 值2
如果条件为真:result = 值1
如果条件为假:result = 值2
1-python自动化
猜你喜欢
转载自www.cnblogs.com/chenming-1998/p/11699529.html
今日推荐
周排行