网站首页
编程语言
数据库
系统相关
其他分享
编程问答
isspace
2024-06-16
python如何判断字符串不为空格
1、使用字符串长度判断。len(s)==0 则字符串为空if len(username) ==0 or len(password) == 0: #判断输入的用户名或密码是否为空 print('用户名或密码不能为空')2、isspace判断是否字符串全部是空格。s.isspace()==Trueif username.isspace(