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