话说我在研究​​pywhatkit​​时搞了一下源程序,发现了这个:

data = requests.get(
f"https:///handwriting?text={string}&rgb={rgb[0]},{rgb[1]},{rgb[2]}"
)

然后,我掏出了​​apifox​​,一试:

Python实现输出手写体图片_python

ohhhhhhhhhhh !

来,说说我发现的东西!


这是一个GET请求的API接口​​​​,两个参数,分别是​​text​​(文字)和​​rgb​​(颜色)。

我找了一段简短的英文小故事来测试。接口无法处理中文。


A child was careless ramie stabbed, he rushed home and told his mother: I only lightly Pengyi what, it was my painful thorns.Mom said: Because of this, it will thorn you. if the next time you met Ramie, to a courageous and seize it, it will be in your hands become soft as silk, you will no longer be is said that many people are serving hard against soft.
Python实现输出手写体图片_源程序_02


我把它写成一个程序,一起来看:

from requests import get
t = input('Enter some English >>> ')
if len(t) > 1035:
print('The content you entered is too long.')
input()
exit()

color = (30,30,150)
params = {
'text':t,
'color':'%d,%d,%d' % (color[0],color[1],color[2])
}
try:
res = get('https:///handwriting',params=params)
with open('text.png','wb') as f:
f.write(res.content)

print('\nSuccessful production.')
input()
except Exception as e:
print('Error :',e)

Python实现输出手写体图片_后端_03

Python实现输出手写体图片_api接口_04