现在的位置: 首页 > 综合 > 正文

python将文字转换成图片

2014年09月17日 ⁄ 综合 ⁄ 共 263字 ⁄ 字号 评论关闭

     现在又很多工具能将文字转换成图片,这样就可以发送长微博,其实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")

抱歉!评论已关闭.