【问题标题】:Accessing the output of a Python program访问 Python 程序的输出
【发布时间】:2018-05-27 12:55:08
【问题描述】:

我在 Python 中使用BitVector。我必须对两个位向量执行 除法

我使用了下面的代码:

from BitVector import*
mod = BitVector( bitstring='1011011' )
n = 6
a = BitVector( intVal = 9223372036854775809 )
quotient, remainder = a.gf_divide(mod, n)
print(quotient)
print(remainder)

我得到的输出如下:

0000001011111100101010001100111101110101101001101100010010000111

0000

我想将quotient 转换为列表。我不能使用命令list{quotient},因为商不是字符串。 print(type(quotient)) 给出输出 <class 'BitVector.BitVector.BitVector'>

如何将quotient 转换为list

【问题讨论】:

  • 虽然this直接回答了你的问题,但很可能不是你想要的。

标签: python string python-3.x list bitvector


【解决方案1】:

list(str(quotinent)) 呢?

【讨论】:

  • 无法正常工作,因为我正在获取符号以及列表中的二进制位。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-12-28
  • 2015-07-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多