[英]How do I write a dictionary info a text file in this format? (Python)
[英]How do I write underline text in text file or in Python?
我尝试了以下方法:
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()
我在命令行中获得了正确的输出,但是在文本文件中,我得到了这样的输出:
"[4mThis is my underline string.[0m"
START = '\\033[4m' END = '\\033[0m'
格式化正确。 如果看到响应cat test_underline.txt
则会显示下划线文字
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.