python 连接 appfog 的 redis 总是不成功

2014-03-27 22:41:20 +08:00
 ccbikai
按照 https://docs.appfog.com/services/redis#redis-vcap 配置的

代码这样写:
os_r=os.getenv("VCAP_SERVICES")
r=redis.Redis(host=os_r['redis-2.2'][0]['credentials']['hostname'], port=os_r['redis-2.2'][0]['credentials']['port'], password=os_r['redis-2.2'][0]['credentials']['password'])

提示错误:
string indices must be integers, not str

port是 int 其他都是 str 没有问题啊
2170 次点击
所在节点    Python
4 条回复
tonic
2014-03-27 22:54:30 +08:00
os_r是一个string
tonic
2014-03-27 22:54:58 +08:00
哦也不一定... 总之都打出来看看是什么吧...
ccbikai
2014-03-27 23:12:49 +08:00
@tonic type了一下,port是int。

其他的本地测试都能调用
ushuz
2014-03-27 23:42:49 +08:00
逐层检查下类型

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/106203

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX