我如何摆脱像字符串这样的“ \ xb0”

我尝试使用python和dll从内存中投射一些数据。

但是有些“ unicode”使我疯狂地使用结构“广播”数据。

我尝试过decode('utf-8'),但遇到过UnicodeDecodeError

我更改了一些结构类型,但没有任何改变。

如何解决此问题?

class NH0__OutBlock(Structure):
    _fields_ = [
        ("hotime",c_char*6),("hotime1",("offerho1",("bidho1",("offerrem1",("bidrem1",("offercnt1",c_char*5),("bidcnt1",("offerho2",("bidho2",("offerrem2",("bidrem2",("offercnt2",("bidcnt2",("offerho3",("bidho3",("offerrem3",("bidrem3",("offercnt3",("bidcnt3",("offerho4",("bidho4",("offerrem4",("bidrem4",("offercnt4",("bidcnt4",("offerho5",("bidho5",("offerrem5",("bidrem5",("offercnt5",("bidcnt5",("totofferrem",("totbidrem",("totoffercnt",("totbidcnt",("futcode",c_char*8)
    ]
...
# RealMsgPacket.contents.pszData Type is ctypes.c_char_p
elif RealMsgPacket.contents.szTrCode.decode('euc-kr') == "NH0":
            Casted = cast(RealMsgPacket.contents.pszData,POINTER(c_char*int(RealMsgPacket.contents.nDataLength)))
            print(Casted.contents.value.strip())
...
b'035822 275822 028345\xb0028340\xb0000012 000019 00004 00016 028350\xb0028335\xb0000014 000025 00007 00022 028355\xb002
8330\xb0000007 000020 00004 00015 028360\xb0028325\xb0000007 000022 00005 00011 028365\xb0028320\xc0000010 000037 00010
00015 000050 000123 00030 00079 101PC000'
jiqingcss 回答:我如何摆脱像字符串这样的“ \ xb0”

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3164323.html

大家都在问