我尝试了以下内容:
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"
答案 0 :(得分:0)
START = '\033[4m'
END = '\033[0m'
bash格式正确。如果您看到回复cat test_underline.txt
,则会显示下划线文字