小编yan*_*ng5的帖子

Cassandra:在session.execute()期间"无法完成对任何主机的操作"

Cassandra版本:1.2.2
Thrift API版本:19.35.0
CQL支持的版本:2.0.0,3.0.1(默认值:3.0.1)
cassandra-driver for python 3.4
运行cassandra/bin/cassandra with sudo

代码示例:

from cassandra.cluster import Cluster
cluster = Cluster()
session = cluster.connect()    # 1
session.execute("use test")    # 2
cluster.shutdown()
Run Code Online (Sandbox Code Playgroud)

#2的错误消息:
session.execute("use test")
文件"cassandra/cluster.py",第1581行,位于cassandra中的cassandra.cluster.Session.execute
文件"cassandra/cluster.py",第3145行. cluster.ResponseFuture.result cassandra.cluster.NoHostAvailable :('无法完成针对任何主机的操作',{})

困惑:
由于代码示例中的#1没有错误,因此连接似乎没问题.但我不太明白为什么查询执行失败.

python cql cassandra

5
推荐指数
1
解决办法
2566
查看次数

捕获交互式Python shell输出以及输入

我想捕获Python shell输出以及发送给它的输入.例如,在以下用例中,help()也应该出现在capture.log的第4行中:

$ echo "help()" | python3 -i > capture.log   2>&1
$ cat capture.log
Python 3.4.2 (default, Oct  8 2014, 10:45:20) 
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 
Welcome to Python 3.4's help utility!

If this is your first time using Python, you should definitely check out
the tutorial on the Internet at http://docs.python.org/3.4/tutorial/.
....
....
Run Code Online (Sandbox Code Playgroud)

python bash shell stdin stdout

4
推荐指数
1
解决办法
679
查看次数

为什么在Python中快速使用[e]*n(用于创建重复n次的单项列表)?

跟进: 在Python中创建单项重复n次的列表

python -m timeit '[0.5]*100000'
1000 loops, best of 3: 382 usec per loop

python -m timeit '[0.5 for i in range(100000)]'
100 loops, best of 3: 3.07 msec per loop
Run Code Online (Sandbox Code Playgroud)

显然,由于range(),第二个较慢.我不知道为什么[e]*n如此之快(或者它是如何在Python内部实现的).

python list

1
推荐指数
1
解决办法
133
查看次数

标签 统计

python ×3

bash ×1

cassandra ×1

cql ×1

list ×1

shell ×1

stdin ×1

stdout ×1