学习使用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"这个是字符串类型"
添加回答
举报
0/150
提交
取消