[英]Include escape sequence in a string sequence in Python 3
I am trying to send data to a thermal printer directly. 我正在尝试直接将数据发送到热敏打印机。
I have the following test data: 我有以下测试数据:
raw_data = bytes ("This is a test", "utf-8")
I would like to include two initial bytes to build the sequence ESC+@ (character ESC is ASCII 27) to initialize the printer. 我想包含两个初始字节来构建序列ESC + @(字符ESC是ASCII 27)来初始化打印机。
How shall I do that? 我该怎么办?
使用\\033
表示ESC
字符。
raw_data = bytes ("\033@This is a test", "utf-8")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.