Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Python2.7中,为什么有时在使用zlib.decompress()后无法打印_Python_Python 2.7_Zlib - Fatal编程技术网

在Python2.7中,为什么有时在使用zlib.decompress()后无法打印

在Python2.7中,为什么有时在使用zlib.decompress()后无法打印,python,python-2.7,zlib,Python,Python 2.7,Zlib,代码是: import zlib; s="witch which has which witches wrist watch"; z=zlib.compress(s); print(len(s)); print(len(z)); print(s); print(z,"\n"); a=zlib.decompress(z); print(a);#here,in console sometimes will stop at here print(zlib.crc32(s)); 为什么?缓冲区有问题

代码是:

import zlib;
s="witch which has which witches wrist watch";
z=zlib.compress(s);
print(len(s));
print(len(z));
print(s);
print(z,"\n");
a=zlib.decompress(z);
print(a);#here,in console sometimes will stop at here 
print(zlib.crc32(s));

为什么?缓冲区有问题?

在我的机器上工作。顺便说一句,如果你使用的是2.7,你不应该把你的打印语句放在括号里。如果这样做,当您尝试打印多个内容时,您将得到奇怪的结果,例如printz,\n将作为元组打印。如果printa语句挂起,我认为您的python安装有严重问题。当然,它可能是a=zlib.decompressz之前的行;是发生挂起的地方,在这种情况下,您的zlib安装可能会出错。无论如何,我可能会尝试重新安装python并重试您的测试。另外,所有的结束分号是怎么回事?print z打印压缩字节,这对于终端来说是随机垃圾。它可能会锁住它或有其他副作用。您应该尝试打印reprz。