简体   繁体   中英

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.

How shall I do that?

使用\\033表示ESC字符。

raw_data = bytes ("\033@This is a test", "utf-8")

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