简体   繁体   中英

How do I write underline text in text file or in Python?

I have tried the following:

test = 'test_underline.txt'

out_file = open(test,'w')

START = '\033[4m'

END = '\033[0m'

t = START + 'This is my underline string.' + END

print(t)

out_file.write(t)

out_file.close()

I am getting the correct output in command line,but in text file i am getting like this :

"[4mThis is my underline string.[0m"

START = '\\033[4m' END = '\\033[0m'

It's format correct to bash. If you see response cat test_underline.txt you get underline text

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