python将文字转换成图片

时间:2014-05-10 04:25:52   收藏:0   阅读:620

     现在又很多工具能将文字转换成图片,这样就可以发送长微博,其实python实现这很容易的,主要就是用到了pygame模块

import os
import pygame
from pygame.locals import *

pygame.init()
 
text = u"这是一段测试文本,test 123。"
font = pygame.font.SysFont(‘SimHei‘, 14)
ftext = font.render(text, True, (0, 0, 0), (255, 255, 255))
 
pygame.image.save(ftext, "t.jpg")

bubuko.com,布布扣

python将文字转换成图片,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!