|
发表于 2024-11-14 03:24:24
|
显示全部楼层
you need to convert file content in hw_ctree.xml to binary data as output.bin2 p- @) K6 N- W7 K& \
8 H& ~, M; ?! W9 c" s7 p1 aPython:# }- N0 L2 ~) ]% N0 G
7 a/ T( @6 V6 @. N% P W) r" S% A* x3 Jimport struct/ R. _2 h4 u( H. J' o# f6 g1 C
0 D7 b0 }) P: h$ K( Z
# to write in- ~" C) |4 A/ {+ q; a: M
data_to_write = "file content" #file content of hw_ctree.xml) H8 T: k- M( t5 K% ?( W/ E0 G
6 X3 ^8 F& E! w" E$ I# open .bin to write- m1 B4 V: T2 ]! a* X# ^ k+ A
with open("output.bin", "wb") as bin_file:/ K( x! p# {- c8 U& Y
# to binary( `, ^1 ]0 @- k# E
binary_data = data_to_write.encode('utf-8')8 P$ s5 E" T, Y! Z/ ]2 d3 ~
0 A0 H: Z O$ n# S. `, i+ l/ e
# to .bin3 m6 W. M I" \- r) k7 L" g. Z- y
bin_file.write(binary_data)
# @6 N5 Z+ P( Z8 X- K
5 d9 m/ H# H) H#So do game over |
|