使用的库import stylecloud
import stylecloud
#stopwords = open('data/stopwords.txt', encoding='utf-8').read().split('\n')
stylecloud.gen_stylecloud(file_path='/Users/yua/Documents/_test/case/constitution.txt',
#font_path="Hiragino Sans GB.ttc",
font_path='SourceHanSansCN-Regular.otf',
icon_name='fas fa-user-graduate',
output_name='1.png',
size=1500
# custom_stopwords=stopwords
)
在实际操作过程中会遇到如下问题:
OSError: cannot open resource
究其原因,是因为本地不存在对应的字体库,随更新:
font_path="Hiragino Sans GB.ttc",
参考链接:
https://blog.csdn.net/weixin_38008864/article/details/107194187
https://fontawesome.com/license/free
网友评论