简体   繁体   中英

Python how to get only the last 2 bytes of the reply data

I will post a query to a device which will return me with something like this (after a readlines):

['\x03C?01FF00\r']

I want to extract just the FF00 and post the reply to the jquery (which sends the query) and display it out on browser. How can i do that? The 2 bytes range from 0000 to FFFF.

EDIT: the reply type is list .

假设ans = ['\\x03C?01FF00\\r'] ,则ans[0].strip()[-4:]应产生'FF00'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM