我的代碼:如何解決TypeError:'str'不支持緩衝區接口?
big_int = 536870912
f = open('sample.txt', 'wb')
for item in range(0, 10):
y = bytearray.fromhex('{:0192x}'.format(big_int))
f.write("%s" %y)
f.close()
我想一個長整型轉換爲字節。但我得到TypeError: 'str' does not support the buffer interface
。
只是嘗試'f.write(y)' –
謝謝,它的工作原理 – rrra