赞
踩
一、使用正则办法
from PyQt5.QtGui import QRegExpValidator
from PyQt5.QtCore import QRegExp
# 只能输入a~z,A~Z,0~9 字符16位内,作用做用户账号
self.QLineEdit.setValidator(QRegExpValidator(QRegExp("[a-zA-Z0-9]{16}"),self))
# 只能输入非中文,但能输入中文特殊字符,16位内,可作密码
self.QLineEdit.setValidator(QRegExpValidator(QRegExp("[^\u4e00-\u9fa5]{16}"),self))
# 只能输入英文、数字、英文特殊字符,限制16位,可作密码
self.user_account_Edit.setValidator(QRegExpValidator(QtCore.QRegExp("[a-zA-Z0-9.@#%*+*/]{16}"),self))
二、使用隐式密码框
from PyQt5 import QtWidgets
self.QLineEdit.setEchoMode(QtWidgets.QLineEdit.Password)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。