2015-02-05 6 views
5

मैं struct मॉड्यूल का उपयोग कर रहा समर्थन नहीं करता है तो जैसे:struct.unpack के कारण लेखन त्रुटि: 'int' अजगर 3.4 में बफर इंटरफ़ेस

b'\x03\x01\x0e}GZ\xa8\x8e!\x1c\x7ft\xe8\xf9G\xbf\xb1\xdf\xbek\x8d\xb3\x05e~]N\x97\xad\xcaz\x03tP\x00\x00\x1eV\x00\xc0\n\xc0\t\xc0\x13\xc0\x14\xc0\x07\xc0\x11\x003\x002\x009\x00/\x005\x00\n\x00\x05\x00\x04\x01\x00\x00f\x00\x00\x00\x1b\x00\x19\x00\x00\x16parteek.khalsabani.com\xff\x01\x00\x01\x00\x00\n\x00\x08\x00\x06\x00\x17\x00\x18\x00\x19\x00\x0b\x00\x02\x01\x00\x00#\x00\x003t\x00\x00\x00\x10\x00\x1b\x00\x19\x08spdy/3.1\x06spdy/3\x08http/1.1\x00\x05\x00\x05\x01\x00\x00\x00\x00' 

मैं:

length = struct.unpack('>B', data[34])[0] 

data इस तरह दिखता है

TypeError: 'int' does not support the buffer interface.

मैं संरचना का उपयोग करने में नया हूं। क्या गलत है?

उत्तर

8

क्योंकि आप data[34] जो की यह सामग्री गुजर रहे हैं यही कारण है कि एक int है।

इसके बजाय data[34:35] का उपयोग करने का प्रयास करें, जो एक तत्व बाइट सरणी है।

संबंधित मुद्दे