![](/img/trans.png)
[英]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.