为了账号安全,请及时绑定邮箱和手机立即绑定

学习python使用rabbitmq,遇到麻烦

学习python使用rabbitmq,遇到麻烦

ABOUTYOU 2019-04-16 20:26:43
学习使用rabbitmq,遇到麻烦python3.3.2rabbitmq3.4.1pika-0.9.14pythonsend.pyTraceback(mostrecentcalllast):File"send.py",line3,inconnection=pika.BlockingConnection(pika.ConnectionParameters(host='localhost'))File"/home/hawk/g/sqlalchemy/lib/python3.3/site-packages/pika/connection.py",line361,in__init__ifhostandself._validate_host(host):File"/home/hawk/g/sqlalchemy/lib/python3.3/site-packages/pika/connection.py",line207,in_validate_hostifnotisinstance(host,basestring):NameError:globalname'basestring'isnotdefined------------------------------------------------------------pythonreceive.pyTraceback(mostrecentcalllast):File"receive.py",line5,inhost='localhost'))File"/home/hawk/g/sqlalchemy/lib/python3.3/site-packages/pika/connection.py",line361,in__init__ifhostandself._validate_host(host):File"/home/hawk/g/sqlalchemy/lib/python3.3/site-packages/pika/connection.py",line207,in_validate_hostifnotisinstance(host,basestring):NameError:globalname'basestring'isnotdefined这是什么情况?===========================Python3.3.2+(default,Feb282014,00:52:16)[GCC4.8.1]onlinuxType"help","copyright","credits"or"license"formoreinformation.>>>importpika>>>connection=pika.BlockingConnection(pika.ConnectionParameters(...host='localhost'))Traceback(mostrecentcalllast):File"",line2,inFile"/home/hawk/g/f3/lib/python3.3/site-packages/pika/connection.py",line361,in__init__ifhostandself._validate_host(host):File"/home/hawk/g/f3/lib/python3.3/site-packages/pika/connection.py",line207,in_validate_hostifnotisinstance(host,basestring):NameError:globalname'basestring'isnotdefinedweb开发flask、sqlalchemy等等都是使用python3,总不至于再回到2.7吧?
查看完整描述

2 回答

?
郎朗坤

TA贡献1921条经验 获得超9个赞

ifnotisinstance(host,basestring):
NameError:globalname'basestring'isnotdefined
说明basestring不存在,你需要import进来或者定义这个变量
如a="test"
ifnotisinstance(a,str):#str是类型的类型,所以不用导入,如果不是就需要导入这个类或者方法
print"不是字符串类型"
else:
print"这个是字符串类型"
                            
查看完整回答
反对 回复 2019-04-16
  • 2 回答
  • 0 关注
  • 587 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信