简体   繁体   English

Python解释器和脚本输出不同的结果

[英]Python interpreter and script outputs different results

I have installed Python 2.7.12. 我已经安装了Python 2.7.12。 I have tried to write some simple script and I got weird result so I run python interpreter and to my surprise I got different results. 我试着写一些简单的脚本,我得到了奇怪的结果,所以我运行python解释器,令我惊讶的是我得到了不同的结果。 Here is my script: 这是我的脚本:

import binascii
import bitarray

a = bitarray.bitarray(1)
a[0] = 0
print a
crc = binascii.crc_hqx(a, 0x0000)
print crc

b = bitarray.bitarray(1)
b[0] = 0
print b
crc = binascii.crc_hqx(b, 0x0000)
print crc

The output of above script is as follows: 上述脚本的输出如下:

bitarray('0')
0
bitarray('0')
33032

Value 33032 is wrong that is why I decided to check it using python interpreter and thats what I get: 值33032是错误的,这就是为什么我决定使用python解释器检查它,这就是我得到的:

Type "help", "copyright", "credits" or "license" for more information.
>>> import binascii
>>> import bitarray
>>> a = bitarray.bitarray(1)
>>> a[0] = 0
>>> print a
bitarray('0')
>>> crc = binascii.crc_hqx(a, 0x0000)
>>> print crc
0
>>> b = bitarray.bitarray(1)
>>> b[0] = 0
>>> print b
bitarray('0')
>>> crc = binascii.crc_hqx(b, 0x0000)
>>> print crc
0
>>> 

I sit in front of the desktop and struggle to find out what is wrong. 我坐在桌面前,努力找出问题所在。

I use bitarray version 0.8.1. 我使用bitarray版本0.8.1。

I did not solve the problem but I can say that I have omitted the problem. 我没有解决问题,但我可以说我省略了问题。 Instead of using bitarray I use bitstring package. 而不是使用bitarray我使用bitstring包。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM