Im not sure why the program return true when the string contains chinese characters.
cop = "奶helloworld茶"
print(cop)
print(cop.isalpha())
print(cop.isalnum())
This gives output like this.
奶helloworld茶
True
True
Im not sure why the program return true when the string contains chinese characters.
cop = "奶helloworld茶"
print(cop)
print(cop.isalpha())
print(cop.isalnum())
This gives output like this.
奶helloworld茶
True
True
Chinese characters are considered alphabetic in Unicode, so isalpha
and isalnum
will return True
for them. If you don't want this, then restrict it to being ascii:
print(cop.isascii() and cop.isalpha()) # False