一,学习py:{} 布尔 del insert input int()字符串为空的判断 elif
1.”a in b”返回布尔值,判断b列表中是否有a。
2.”x.insert(位置,”内容”)”在列表x中插入数据。
3.“del .x”可以用来删除变量和列表中的值。
4.input 读取的值都是字符串
5.使用“int”关键字来将变量转换为int类型,ex:print( int(a) )
6.使用“{}”在字符串中引用变量(需要在字符串最前面引号前面加上“f”)
7.关于字符串为空的判断
len(s) ==0
ex:len(s) ==0 则字符串为空if len(username) ==0 or len(password) == 0: #判断输入的用户名或密码是否为空
isspace判断是否字符串全部是空格
s.isspace() == Trueif username.isspace() or password.isspace(): #判断输入的用户名或密码是否为空
8.
去两边空格:str.strip()
去左空格:str.lstrip()
去右空格:str.rstrip()
去两边字符串:str.strip(‘d’),相应的也有lstrip,rstrip。
9.”if”后面用冒号”:{}”
10.py中的else if = elif
参考文章:https://blog.csdn.net/weixin_39725118/article/details/111822050