python怎么给黑体字体转换器加粗

I want to be able to change the text to bold in Python. Is there a way to do that?
I have been able to change colors with termcolor but nothing so far with bold text. Has anyone tried doing it before?
解决方案 You might want to try ANSI escape sequences if your platform allows it.
Crossposting from related - and possible duplicate - SO questions:
Before you proceed, please read the warnings in the above links to make sure your operating system and Python version will allow you to properly render this.
You can define a class containing all of the ANSI escape sequences you need.
class style:
BOLD = '\033[1m'
END = '\033[0m'
Then print them via concatenated class calls:
print style.BOLD + 'This is my text string.' + style.END
If you don't want to go through the hassle of creating an entire class just to get bold text, you can obviously concatenate them directly instead. However, if your code is open-source and not for personal use, make sure you tell other potential readers what this does!
print '\033[1m' + 'This is my text string.' + '\033[0m'
Does this answer your question?
Edit: JYelton beat me to it. I'm such a slow typer...
本文地址: &
我希望能够在Python中将文本更改为粗体。有没有办法做到这一点?
我已经能够用termcolor改变颜色,但没有用粗体文本。有没有人尝试过这样做?
如果您的平台可能要尝试ANSI转义序列允许它。
从相关的crossposting
- 可能的重复 -
在继续之前,请阅读上述链接中的警告信息,以确保您的操作系统和Python版本可以正确呈现。
您可以定义一个包含您所需的所有ANSI转义序列的类。
class style: BOLD ='\033 [1m' END ='\033 [0m'
然后打印通过串联的类调用:
打印样式.BOLD +“这是我的文本字符串。”+样式。 END
如果您不想经历创建整个班级的麻烦,文本,你可以直接将它们直接连接起来。但是,如果你的代码是开源的,而不是个人使用,请确保你告诉其他潜在的读者这是什么!
打印'\033 [1m'+'这是我的文本字符串'+'\033 [0m'
这是否回答您的问题?
编辑:JYelton击败了我。我是一个缓慢的typer ...
本文地址: &
扫一扫关注IT屋
微信公众号搜索 “ IT屋 ” ,选择关注
与百万开发者在一起
(window.slotbydup = window.slotbydup || []).push({
id: '5828425',
container: s,
size: '300,250',
display: 'inlay-fix'Python 对文本汇总产生的文件内容进行可视化
(加粗汇总内容)
#!/usr/bin/python
# -*- coding: utf-8 -*-
Created on
@author: beyondzhou
@name: visualize_document_summary.py
import json
from IPython.display import IFrame
from IPython.core.display import display
from summary import summarize
# Download nltk packages used in this example
#nltk.download('stopwords')
# Read data
BLOG_DATA = r"E:\eclipse\Web\dFile\feed.json"
blog_data = json.loads(open(BLOG_DATA).read())
HTML_TEMPLATE = """&html&
&title&%s&/title&
&meta http-equiv="Content-Type" content="text/ charset=UTF-8"/&
&body&%s&/body&
&/html&"""
for post in blog_data:
# Uses previously defined summarize function.
post.update(summarize(post['content']))
# You could also store a version of the full post with key sentences
# marked up for analysis with simple string replacement
for summary_type in ['top_n_summary', 'mean_scored_summary']:
post[summary_type + '_marked_up'] = '&p&%s&/p&' % (post['content'], )
for s in post[summary_type]:
post[summary_type + '_marked_up'] = \
post[summary_type + '_marked_up'].replace(s, '&strong&%s&/strong&' % (s, ))
filename = post['title'].replace("?", "") + '.summary.' + summary_type + '.html'
f = open(os.path.join(r"E:", "\\", "eclipse", "Web", "dfile", filename), 'w')
html = HTML_TEMPLATE % (post['title'] + \
' Summary', post[summary_type + '_marked_up'],)
f.write(html.encode('utf-8'))
print "Data written to", f.name
# Display any of these files with an inline frame. This displays the
# last file processed by using the last value of f.name...
print "Displaying %s:" % f.name
display(IFrame('files/%s' % f.name, '100%', '600px'))Data written to E:\eclipse\Web\dfile\Four short links: 23 January 2015.summary.top_n_summary.html
Data written to E:\eclipse\Web\dfile\Four short links: 23 January 2015.summary.mean_scored_summary.html
Data written to E:\eclipse\Web\dfile\Designing on a system level.summary.top_n_summary.html
Data written to E:\eclipse\Web\dfile\Designing on a system level.summary.mean_scored_summary.html
Data written to E:\eclipse\Web\dfile\Bitcoin is just the first app to use blockchain technology.summary.top_n_summary.html
Data written to E:\eclipse\Web\dfile\Bitcoin is just the first app to use blockchain technology.summary.mean_scored_summary.html
Data written to E:\eclipse\Web\dfile\Blockchain scalability.summary.top_n_summary.html
Data written to E:\eclipse\Web\dfile\Blockchain scalability.summary.mean_scored_summary.html
Data written to E:\eclipse\Web\dfile\Bringing an end to synthetic biology’s semantic debate.summary.top_n_summary.html
Data written to E:\eclipse\Web\dfile\Bringing an end to synthetic biology’s semantic debate.summary.mean_scored_summary.html
Data written to E:\eclipse\Web\dfile\Building and deploying large-scale machine learning pipelines.summary.top_n_summary.html
Data written to E:\eclipse\Web\dfile\Building and deploying large-scale machine learning pipelines.summary.mean_scored_summary.html
Data written to E:\eclipse\Web\dfile\Four short links: 22 January 2015.summary.top_n_summary.html
Data written to E:\eclipse\Web\dfile\Four short links: 22 January 2015.summary.mean_scored_summary.html
Data written to E:\eclipse\Web\dfile\How to make a UX designer.summary.top_n_summary.html
Data written to E:\eclipse\Web\dfile\How to make a UX designer.summary.mean_scored_summary.html
Data written to E:\eclipse\Web\dfile\The 3Ps of the blockchain: platforms, programs and protocols.summary.top_n_summary.html
Data written to E:\eclipse\Web\dfile\The 3Ps of the blockchain: platforms, programs and protocols.summary.mean_scored_summary.html
Data written to E:\eclipse\Web\dfile\Four short links: 21 January 2015.summary.top_n_summary.html
Data written to E:\eclipse\Web\dfile\Four short links: 21 January 2015.summary.mean_scored_summary.html
Data written to E:\eclipse\Web\dfile\The Internet of Things is really about software.summary.top_n_summary.html
Data written to E:\eclipse\Web\dfile\The Internet of Things is really about software.summary.mean_scored_summary.html
Data written to E:\eclipse\Web\dfile\What containers can do for you.summary.top_n_summary.html
Data written to E:\eclipse\Web\dfile\What containers can do for you.summary.mean_scored_summary.html
Data written to E:\eclipse\Web\dfile\Four short links: 20 January 2015.summary.top_n_summary.html
Data written to E:\eclipse\Web\dfile\Four short links: 20 January 2015.summary.mean_scored_summary.html
Data written to E:\eclipse\Web\dfile\Striking parallels between mathematics and software engineering.summary.top_n_summary.html
Data written to E:\eclipse\Web\dfile\Striking parallels between mathematics and software engineering.summary.mean_scored_summary.html
Data written to E:\eclipse\Web\dfile\Four short links: 19 January 2015.summary.top_n_summary.html
Data written to E:\eclipse\Web\dfile\Four short links: 19 January 2015.summary.mean_scored_summary.html
Displaying E:\eclipse\Web\dfile\Four short links: 19 January 2015.summary.mean_scored_summary.html
使用Python写入docx文件并控制字体颜色
Python中设置输出文字的颜色
Python中输出字体的颜色设置
Python PIL ImageDraw 和ImageFont模块学习
Python在图片中添加文字的两种操作
Python 读取txt文件中的数据并绘制出图形
文本可视化[二]——《今生今世》人物关系可视化python实现
没有更多推荐了,pycharm 使用心得(二)设置字体大小
转载 &更新时间:日 14:51:19 & 作者:
pycharm 是很好的一个IDE,在windows下,和macOS下,都能很好的运行。唯一缺点是启动慢。默认字体太小,在mac下,需要瞪大24K氪金狗眼才能看清。 为了保护好眼睛,我们需要把字体调整大一些:
Settings--&Editor--&Colors & Fonts--&Font
然后在size那里调整。
您可能感兴趣的文章:
大家感兴趣的内容
12345678910
最近更新的内容
常用在线小工具拒绝访问 | www.th7.cn | 百度云加速
请打开cookies.
此网站 (www.th7.cn) 的管理员禁止了您的访问。原因是您的访问包含了非浏览器特征(43e5dfba54f8438e-ua98).
重新安装浏览器,或使用别的浏览器如何在后台实现可以改变前台的信息标题的字体的样式和颜色,类如加粗,变色了
[问题点数:50分]
本版专家分:0
结帖率 20%
CSDN今日推荐
本版专家分:518
本版专家分:0
本版专家分:967
本版专家分:967
本版专家分:316
本版专家分:839
本版专家分:2046
匿名用户不能发表回复!|
其他相关推荐}

我要回帖

更多关于 艺术字体在线转换 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信