84669 人学习
152542 人学习
20005 人学习
5487 人学习
7821 人学习
359900 人学习
3350 人学习
180660 人学习
48569 人学习
18603 人学习
40936 人学习
1549 人学习
1183 人学习
32909 人学习
if not isinstance(host, basestring):
NameError: global name 'basestring' is not defined
说明basestring 不存在, 你需要import 进来或者定义这个变量 如 a="test" if not isinstance(a, str): #str 是类型的类型, 所以不用导入, 如果不是就需要导入这个类或者方法 print "不是字符串类型" else: print "这个是字符串类型"
python3 里已经没有basestring 类型了,你可以做转换啊。请参考这个http://woodpecker.org.cn/peintopython3/porting-code-to-python-3-with-2to3.html
if not isinstance(host, basestring):
NameError: global name 'basestring' is not defined
说明basestring 不存在, 你需要import 进来或者定义这个变量
如 a="test"
if not isinstance(a, str): #str 是类型的类型, 所以不用导入, 如果不是就需要导入这个类或者方法
print "不是字符串类型"
else:
print "这个是字符串类型"
python3 里已经没有basestring 类型了,你可以做转换啊。请参考这个http://woodpecker.org.cn/peintopython3/porting-code-to-python-3-with-2to3.html