学习python使用rabbitmq,遇到麻烦
巴扎黑
巴扎黑 2017-04-17 13:51:29
0
2
408
巴扎黑
巴扎黑

全員に返信(2)
刘奇

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 "这个是字符串类型"

いいねを押す +0
Ty80

python3 里已经没有basestring 类型了,你可以做转换啊。请参考这个http://woodpecker.org.cn/peintopython3/porting-code-to-python-3-with-2to3.html

いいねを押す +0
人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート
私たちについて 免責事項 Sitemap
PHP中国語ウェブサイト:福祉オンライン PHP トレーニング,PHP 学習者の迅速な成長を支援します!