1000字范文,内容丰富有趣,学习的好帮手!
1000字范文 > python print 字体大小 Python-更改打印控制台字体系列/样式

python print 字体大小 Python-更改打印控制台字体系列/样式

时间:2018-12-26 20:31:58

相关推荐

python print 字体大小 Python-更改打印控制台字体系列/样式

The question's straightforward, is it possible to change the font family of text in a Python print() output? Like Times New Roman, Arial, or Comic Sans?

I only want to change some of the output. Not all of the text like in this question.

I'm using Python 3, Jupyter Notebooks on a Mac.

I know it's possible to make certain text bold like so:

bold_start = '\033[1m'

bold_end = '\033[0m'

print(bold_start, "Hello", bold_end, "World")

This outputs "Hello World" instead of "Hello World" or "Hello World"

解决方案

Python strings are just strings of unicode characters, they don't say anything about font one way or another. The font is determined by whatever is rendering the characters, e.g. the terminal program you're using, or the browser you're using. The print function just spits out the resulting string. As you pointed out, if you're in a terminal that understands those escape sequences, then you can use those to affect the output. If your output is a web page, then you can embed html code to specify whatever you like, but all the python interpreter sees is a string of characters, not a string of characters in any particular font.

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。