亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
查看: 3076 | 回復: 4
打印 上一主題 下一主題

unpack 求助 [復制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報告]
發(fā)表于 2010-05-31 12:15 |只看該作者 |倒序瀏覽
有個網(wǎng)絡(luò)數(shù)據(jù)包要解包,本來以為這樣兩句話可以搞定
        for data in fileListData:
            print len(data)
            formatstr=(len(data)/50)*"33scII8s"
            templist=struct.unpack(formatstr,data)
可是它提示格式化字符串和數(shù)據(jù)長度不匹配,最后化成這樣寫才通過了,我看不出來這是什么區(qū)別?
        for data in fileListData:
            print len(data)
            formatstr=(len(data)/50)*"50s"
            templist=struct.unpack(formatstr,data)
            formatstr="33sc16s"
            formatstr2="II8s"
            for i in templist:
                #print i
                temp2=struct.unpack(formatstr,i)
                temp3=struct.unpack(formatstr2,temp2[2])
                self.ncfileInfo.append((temp2[0],temp2[1],temp3[1],temp3[0]))
數(shù)據(jù)我保證都是50的倍數(shù)長,抓包檢驗過的。

論壇徽章:
0
2 [報告]
發(fā)表于 2010-05-31 12:42 |只看該作者
給個數(shù)據(jù)吧。

論壇徽章:
0
3 [報告]
發(fā)表于 2010-05-31 12:56 |只看該作者
(len(data)/50)*"33sc16s"能不能通過?會不會是對齊的影響?
format  I  有個notes(3)
To align the end of a structure to the alignment requirement of a particular type, end the format with the code for that type with a repeat count of zero.

論壇徽章:
0
4 [報告]
發(fā)表于 2010-06-22 15:10 |只看該作者
python的unpack有點不一樣,你傳過來的有可能是用別的語言pack的吧,perl還是php還是其它的,最好再把系統(tǒng)環(huán)境說一下

論壇徽章:
0
5 [報告]
發(fā)表于 2010-06-22 17:39 |只看該作者
手冊里面寫得明白……
  1. >>> s.calcsize('33scII8s')
  2. 52
復制代碼
  1. >>> s.calcsize('=33scII8s')
  2. 50
  3. >>> s.calcsize('!33scII8s')
  4. 50
復制代碼
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報專區(qū)
中國互聯(lián)網(wǎng)協(xié)會會員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP