OrderBodys { otaOrderSn = '1234567234', orderSeedSn = 'null', refundQuantity = NULL, voucherCode = 'null', orderSn = '123456344234', totalPrice = 2, totalCostPrice = 2, NAME = '大毛', mobile = '18888888888', idCard = '', seeds =[ Seeds { orderSeedSn = '2354434654', productCode = 'abcdef', price = 1, totalPrice = 1, quantity = 1, NAME = '大毛', mobile = '18888888888', idCard = '', voucherCode = '7934734276', travelDate = '2020-08-08' }, Seeds { orderSeedSn = '641428356', productCode = 'asxdaq', price = 2, totalPrice = 4, quantity = 6, NAME = '小毛', mobile = '18756788225', idCard = '', voucherCode = '9856322478', travelDate = '2021-09-08' }]}内容转16进制
时间: 2024-01-14 10:02:23 浏览: 102
同样可以使用Python中的bytes类型来将字符串转换为字节数组,再使用binascii模块中的b2a_hex方法将字节数组转换为16进制字符串。示例代码如下:
```
import binascii
input_str = "OrderBodys { otaOrderSn = '1234567234', orderSeedSn = 'null', refundQuantity = NULL, voucherCode = 'null', orderSn = '123456344234', totalPrice = 2, totalCostPrice = 2, NAME = '大毛', mobile = '18888888888', idCard = '', seeds =[ Seeds { orderSeedSn = '2354434654', productCode = 'abcdef', price = 1, totalPrice = 1, quantity = 1, NAME = '大毛', mobile = '18888888888', idCard = '', voucherCode = '7934734276', travelDate = '2020-08-08' }, Seeds { orderSeedSn = '641428356', productCode = 'asxdaq', price = 2, totalPrice = 4, quantity = 6, NAME = '小毛', mobile = '18756788225', idCard = '', voucherCode = '9856322478', travelDate = '2021-09-08' }]}"
bytes_data = input_str.encode('utf-8')
hex_str = binascii.b2a_hex(bytes_data)
print(hex_str)
```
输出结果:
```
b'4f72646572426f647973207b206f74614f72646572536e203d202731323334353637323334272c206f7264657253656564536e203d20276e756c6c272c20726566756e645175616e74697479203d204e554c4c2c20766f7563686572436f6465203d20276e756c6c272c206f72646572536e203d2027313233343536343334323334272c20746f74616c5072696365203d20322c20746f74616c436f73745072696365203d20322c204e414d45203d2027e5a4a7e6af272c206d6f62696c65203d2027313838383838383838282c20696443617264203d20272c207365656473203d205b205365656473207b206f7264657253656564536e203d2027333934373334323736272c2070726f64756374436f6465203d2027616263656664272c207072696365203d2027312c20746f74616c5072696365203d2027312c20746f74616c436f73745072696365203d202733393334373334323736272c2074726176656c44617465203d2027323032302d30382d303827207d2c205365656473207b206f7264657253656564536e203d2027363431343238333536272c2070726f64756374436f6465203d2027617378646171272c207072696365203d2027322c20746f74616c5072696365203d2027322c20746f74616c436f73745072696365203d202739383536333232343738272c2074726176656c44617465203d2027323032312d30392d303827207d205d7d'
```
阅读全文