x
模块检查字符串re
是否具有大写,小写和数字。为什么第9行抛出
AttributeError: '<invalid type>' object has no attribute 'sub' on line 9 in main.py
难道不就叫re.sub
吗?
import re as regex
x = input()
y = 0
uppercase = 0
lowercase = 0
num = 0
def next():
if len(regex.sub(r'[a-z]', '', x)) != len(x):
lowercase = 1
if len(regex.sub(r'[A-Z]', '', x)) != len(x):
uppercase = 1
if len(regex.sub(r'[1-9]', '', x)) != len(x):
num = 1
if len(x) >= 6:
if len(x) <= 12:
next()
else:
print("NOPE, between 6,12 chars")
else:
print("NOPE, between 6,12 chars")
答案 0 :(得分:0)
错误的原因是因为我使用的在线编译器有一个名为re.py的文件