使用彩色将print()控制台日志 [英] print() to console log with color
本文介绍了使用彩色将print()控制台日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
代码是:
let redColor = "\u{001B}[0;31m"
var message = "Some Message"
print(redColor + message) //This doesn't work
print("\(redColor)\(message)") //This also doesn't work
,输出将如下所示:
[0;31mSome Message
我也阅读了这篇文章:使用Swift命令行工具进行颜色输出,它似乎不起作用.
I've also read this post: Color ouput with Swift command line tool, and it doesn't seem to work.
我不想使用库.
推荐答案
如今,Xcode调试控制台不支持着色.
Nowadays, Xcode debugging console doesn't support coloring.
这篇关于使用彩色将print()控制台日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文