简体   繁体   中英

how to write unreadable ^A into output file in Python?

Wondering how to write unreadable ^A into a file using Python. For unreadable ^A, I mean when we use command "set list" in vi, we can see unreadable character like ^I for '\\t', $ for '\\n'.

thanks in advance, Lin

If you know the character code, you can output it using the chr() function. For example:

>>> chr(97)
'a'

Do you mean the Start of Header character?

在此输入图像描述

If so, then use this:

chr(1)

Another way to do it is '\\1'. Cheers!

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