为了账号安全,请及时绑定邮箱和手机立即绑定

为什么打印打包的int会吓坏OS X?

为什么打印打包的int会吓坏OS X?

UYOU 2021-03-28 16:13:42
在终端中打印二进制打包的随机数时,它会生成一堆警报。该程序的代码是:from struct import pack, unpackimport hashlibimport sysprint "Input the message you want to work on:"message = raw_input()orig_hash = hashlib.sha512(message).digest()trialValue = 99999999999999999999target = 4103215547750nonce = 0while trialValue > target:nonce += 1packed_nonce = pack('>Q', nonce)print packed_noncetrialValue, = unpack('>Q',hashlib.sha512(packed_nonce + orig_hash).digest()[0:8])print nonceprint trialValue这没什么大不了的,但是没有人知道为什么会这样吗?
查看完整描述

1 回答

?
互换的青春

TA贡献1797条经验 获得超6个赞

可能是因为您要打印的某些数据包含BEL(0x07)字符,这会导致终端发出蜂鸣声。

除非您希望终端做一些奇怪的事情,否则不要打印控制字符。


查看完整回答
反对 回复 2021-04-05
  • 1 回答
  • 0 关注
  • 152 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号