Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/281.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
Python While循环仅打印列表中的2字节数据_Python - Fatal编程技术网

Python While循环仅打印列表中的2字节数据

Python While循环仅打印列表中的2字节数据,python,Python,我是Python新手。 我在写简单的while循环: response = '11 22 00 33 44 00 00 55 66 00 00 00 00 77 88 00 00' LocalDataAry = response.split() exit = 'false' index = 0 while(exit != 'true'): PID = int(LocalSsDataAry[index],16) PID = PID << 8 PID = hex(PI

我是Python新手。 我在写简单的while循环:

response = '11 22 00 33 44 00 00 55 66 00 00 00 00 77 88 00 00'
LocalDataAry = response.split()
exit = 'false'

index = 0
while(exit != 'true'):
   PID = int(LocalSsDataAry[index],16)
   PID = PID << 8
   PID = hex(PID | int(LocalSsDataAry[index+1],16))[2:].upper()
   print PID
   index += 1
但我希望我的输出显示如下:

1122
3344
5566
7788

我该怎么做。

响应='11 22 00 33 44 00 00 55 66 00 00 00 00 00 77 88 00'计算前2字节数据的大小。

Like
11 22
有1个字节
00

“33 44”有2个字节
00

根据大小使用
if
语句

您将拥有无限循环,因为您的
退出
不会改变。(1)您在一次循环迭代中处理2个项目,但只将
索引
增加1;(2) 您对待
00
值没有任何不同,您的程序如何知道不应该打印它们?(提示:如果,请使用
)@vishes\u shell,您的答案是否可以帮助我解决问题question@SurendraKathari我不确定,你应该自己尝试一下,但我认为这不会有帮助,因为不清楚你的程序中发生了什么。
1122
3344
5566
7788