Search This Blog

python: check if a variable is a string


import sys

if isinstance(var, basestring if sys.version_info[0]<3 else str):
print("it is string") # var is string

see also

No comments:

Post a Comment