当前位置: 首页>>代码示例>>Python>>正文


Python BitArray.insert方法代码示例

本文整理汇总了Python中bitstring.BitArray.insert方法的典型用法代码示例。如果您正苦于以下问题:Python BitArray.insert方法的具体用法?Python BitArray.insert怎么用?Python BitArray.insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bitstring.BitArray的用法示例。


在下文中一共展示了BitArray.insert方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _ensure_padding

# 需要导入模块: from bitstring import BitArray [as 别名]
# 或者: from bitstring.BitArray import insert [as 别名]
    def _ensure_padding(self, cipher_stream):
        stream = BitArray(hex=cipher_stream)
        stream_len = stream.len
        while stream_len % 8:
            stream.insert('0b0', 0)
            stream_len = stream_len + 1

        return stream
开发者ID:sescandor,项目名称:myCryptoPalsSolutions,代码行数:10,代码来源:challenge_3.py

示例2: string_to_bitarray

# 需要导入模块: from bitstring import BitArray [as 别名]
# 或者: from bitstring.BitArray import insert [as 别名]
	def string_to_bitarray(self, _string, _maxsize=448):
		b = BitArray()
		pos = 0
		if (_string):
			for c in _string:
				c_str = "{:#09b}".format(ord(c))
				print("{:s}:{:s}".format(c, c_str))
				b.insert(c_str, pos)
				pos += 7
		if (len(b.bin) < _maxsize):
			b.insert("{:#09b}".format(TERMINATOR), pos)
		if (len(b.bin) > _maxsize):
			raise Exception("Size of bit array exceeds the maximum size allowed ({:d}).".format(_maxsize))
		return b
开发者ID:InfectedPacket,项目名称:Vmfcat,代码行数:16,代码来源:Fields.py

示例3: testInsert

# 需要导入模块: from bitstring import BitArray [as 别名]
# 或者: from bitstring.BitArray import insert [as 别名]
 def testInsert(self):
     s = BitArray("0b00")
     s.insert("0xf", 1)
     self.assertEqual(s, "0b011110")
开发者ID:juanrmn,项目名称:Arduino-Telescope-Control,代码行数:6,代码来源:test_bitarray.py


注:本文中的bitstring.BitArray.insert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。