我想創建一個格式化在Python中的查詢,我想不出如何我可以字符串轉義數據的二進制輸入。它返回如下內容:Python格式化字符串轉義
INSERT INTO
python
。UDP
(Packet
,Destination
,Source
,Protocol
,Version
,Header_Length
,TTL
,Protoco l_UDP
,Target
,Source_Port
,Destination_Port
,Length
)VALUES(NULL,'00:0C:29:B2:14:0℃下」, '192.168.178.50', '8','4','20','128','17','192.168.178.24','52371','8888','29227','b'Data \ x00 \ x00 \ x00 \ x00 \ X00 \ X00 \ X00 \ X00 \ X00 \ X00 \ X00 \ X00 \ X00 \ X00 '');)
你怎麼能正確地逃避與蟒蛇格式的二進制字符串值?
def setopUDP(destination, source, protocol, version, header_length, ttl, protocolEGP, target, source_port, destination_port, length, data):
query = ("INSERT INTO `python`.`UDP` (`Packet`, `Destination`, `Source`, `Protocol`, "
"`Version`, `Header_Length`, `TTL`, `Protocol_UDP`, `Target`, `Source_Port`, "
"`Destination_Port`, `Length`) VALUES (NULL, '{}', '{}', '{}', '{}', '{}', '{}', '{}', '{}', '{}', '{}', '{}', '{}');)"
.format(destination, source, protocol, version, header_length, ttl, protocolEGP, target, source_port, destination_port, length, data))
setopCON(query)
你用什麼數據庫適配器? –