学习python使用rabbitmq,遇到麻烦

学习使用rabbitmq,遇到麻烦
python3.3.2
rabbitmq3.4.1
pika-0.9.14
pythonsend.py
Traceback(mostrecentcalllast):
File"send.py",line3,in
connection=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_host
ifnotisinstance(host,basestring):
NameError:globalname'basestring'isnotdefined
------------------------------------------------------------
pythonreceive.py
Traceback(mostrecentcalllast):
File"receive.py",line5,in
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_host
ifnotisinstance(host,basestring):
NameError:globalname'basestring'isnotdefined
这是什么情况?
===========================
Python3.3.2+(default,Feb282014,00:52:16)
[GCC4.8.1]onlinux
Type"help","copyright","credits"or"license"formoreinformation.
>>>importpika
>>>connection=pika.BlockingConnection(pika.ConnectionParameters(
...host='localhost'))
Traceback(mostrecentcalllast):
File"",line2,in
File"/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_host
ifnotisinstance(host,basestring):
NameError:globalname'basestring'isnotdefined
web开发flask、sqlalchemy等等都是使用python3,总不至于再回到2.7吧?
ABOUTYOU
浏览 588回答 2
2回答

郎朗坤

ifnotisinstance(host,basestring):NameError:globalname'basestring'isnotdefined说明basestring不存在,你需要import进来或者定义这个变量如a="test"ifnotisinstance(a,str):#str是类型的类型,所以不用导入,如果不是就需要导入这个类或者方法print"不是字符串类型"else:print"这个是字符串类型"
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript