String string:
String .isalnum () All characters are numbers or letters, is true returns Ture, otherwise False.
String .isalpha () All characters are letters, is true returns Ture, otherwise False.
String .isdigit () All characters are numeric, true return Ture, otherwise False.
String .islower () are all lowercase characters, true return Ture, otherwise False.
String .isupper () All characters are uppercase, true return Ture, otherwise False.
String .istitle () all words are capitalized, is true returns Ture, otherwise False.
String .isspace () all characters are blank characters, true return Ture, otherwise False.
isinstance(o,t):
- 字符串、int、long、float - isinstance(data, (int, str, types.LongType, float))
- Time Type - isinstance (data, datetime.datetime)
- Boolean - isinstance (data, (bool))
- Dictionary Type - isinstance (data, (dict))
- Array - isinstance (data, (list))
- unicode - isinstance(data, unicode)
- mongo obJect - isinstance(data, bson.objectid.ObjectId)
type (): do not think the parent class is a subclass
isinstance (): think subclass is the parent class type
class Color(object):
pass
class Red(Color):
pass
print(type(Color()) == Color)#->True
print(type(Red()) == Color)#->False
print(isinstance(Red(), Color))#->True