完全可以,你只要定義好線段的坐標,按照坐標畫線即可 write函數就可以寫字了啊...... 你們要的Python寫漢字,今天安排! #!/usr/bin/env python3 # -*- coding: utf-8 -*- """ @author: xufeng @contact:326939406@qq.com @version: 1.0.0 @license: Apache Licence @file: write_name.py @time: 8/2/20 20:07 """ import requests import urllib.parse import re from turtle import * headers = { authority: bihua.51240.com, pragma: no-cache, cache-control: no-cache, user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84. 0.4147.105 Safari/537.36, dnt: 1, accept: */*, sec-fetch-site: same-origin, sec-fetch-mode: cors, sec-fetch-dest: empty, referer: https://bihua.51240.com/, accept-language: en,zh-CN;q=0.9,zh;q=0.8, cookie: __gads=ID=658c828707dd0499:T=1595998724:S=ALNI_MZ6bsw6q1nu1qsbMrUf73nv50vfxw; BAIDU_SSP_lcr=https://www.baidu.com/link?url=SXNjkUiTyzcsX7f1yrBwTjsy8mJmkaLnMv vfHPMFi7vXJueYvk5Sc1vKwnVXf4Sewd=eqid=d9851dee00006859000000055f26ece8; Hm_lv t_fbe0e02a7ffde424814bef2f6c9d36eb=1595998724,1596386543; c_y_g_j=bihua%2Cjing weidu; Hm_lpvt_fbe0e02a7ffde424814bef2f6c9d36eb=1596386739, } def gen_url_encode_words(words): source = for i in range(len(words)): _data = words[i] if i == 0: source = urllib.parse.quote(_data).replace("%", ).lower() else: source = source + $ + urllib.parse.quote(_data).replace("%", ).lower() return source def setting(): # 參數設置 pensize(4) hideturtle() colormode(255) color((250, 0, 0), "red") speed(1) if __name__ == __main__: target_words = 無用之用是為大用 params = ( (font, gen_url_encode_words(target_words)), (shi_fou_zi_dong, 0), (cache_sjs1, 20031908), ) response = requests.get(https://bihua.51240.com/web_system/51240_com_www/system/file/bihua/get_0/, headers=headers, params=dict(params) ) content = response.content.decode(utf-8) content = content.replace(hzbh.main(, ).split();document.getElementById)[0] content = content.split({)[-1].split("}")[0] pattern = re.compile(rw:[(.+?)]) result1 = re.split(pattern, content) words_order_list = {} words_cnt = 0 for r in result1: sec = re.findall(r.+?, r) if len(sec): orders = sec[1].split(#) order_xy_routine = [] for order in orders: order_str = re.findall(r(d+,d+), order) order_xy = [eval(xy) for xy in order_str] order_xy_routine.append(order_xy) words_order_list[{}_{}.format(words_cnt, target_words[words_cnt])] = order_xy_routine words_cnt += 1 setting() # 畫布、畫筆設置 right_shift = 0 down_shift = 0 for k, v in words_order_list.items(): for lines in v: pu() for xy in lines: x, y = xy x, y = x * 0.2 - 400 + right_shift * 200, -y * 0.2 + 250 - down_shift * 200 goto(x, y) pd() right_shift += 1 if right_shift % 4 == 0: down_shift += 1 right_shift = 0 done() 筆順來自網路,可能有誤!代碼中可以找到該網站。 另外新人求贊!求贊!求贊! 可以呀,調用write函數。不只是可以寫,還可以選擇字體類型,對齊方式等等 可以寫文本 推薦閱讀:
完全可以,你只要定義好線段的坐標,按照坐標畫線即可
write函數就可以寫字了啊......
你們要的Python寫漢字,今天安排!
#!/usr/bin/env python3 # -*- coding: utf-8 -*-
""" @author: xufeng @contact:326939406@qq.com @version: 1.0.0 @license: Apache Licence @file: write_name.py @time: 8/2/20 20:07 """
import requests import urllib.parse import re from turtle import *
headers = { authority: bihua.51240.com, pragma: no-cache, cache-control: no-cache, user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84. 0.4147.105 Safari/537.36, dnt: 1, accept: */*, sec-fetch-site: same-origin, sec-fetch-mode: cors, sec-fetch-dest: empty, referer: https://bihua.51240.com/, accept-language: en,zh-CN;q=0.9,zh;q=0.8, cookie: __gads=ID=658c828707dd0499:T=1595998724:S=ALNI_MZ6bsw6q1nu1qsbMrUf73nv50vfxw; BAIDU_SSP_lcr=https://www.baidu.com/link?url=SXNjkUiTyzcsX7f1yrBwTjsy8mJmkaLnMv vfHPMFi7vXJueYvk5Sc1vKwnVXf4Sewd=eqid=d9851dee00006859000000055f26ece8; Hm_lv t_fbe0e02a7ffde424814bef2f6c9d36eb=1595998724,1596386543; c_y_g_j=bihua%2Cjing weidu; Hm_lpvt_fbe0e02a7ffde424814bef2f6c9d36eb=1596386739, }
def gen_url_encode_words(words): source = for i in range(len(words)): _data = words[i] if i == 0: source = urllib.parse.quote(_data).replace("%", ).lower() else: source = source + $ + urllib.parse.quote(_data).replace("%", ).lower() return source
def setting(): # 參數設置 pensize(4) hideturtle() colormode(255) color((250, 0, 0), "red") speed(1)
if __name__ == __main__: target_words = 無用之用是為大用 params = ( (font, gen_url_encode_words(target_words)), (shi_fou_zi_dong, 0), (cache_sjs1, 20031908), )
response = requests.get(https://bihua.51240.com/web_system/51240_com_www/system/file/bihua/get_0/, headers=headers, params=dict(params) )
content = response.content.decode(utf-8)
content = content.replace(hzbh.main(, ).split();document.getElementById)[0] content = content.split({)[-1].split("}")[0] pattern = re.compile(rw:[(.+?)]) result1 = re.split(pattern, content) words_order_list = {} words_cnt = 0 for r in result1: sec = re.findall(r.+?, r) if len(sec): orders = sec[1].split(#) order_xy_routine = [] for order in orders: order_str = re.findall(r(d+,d+), order) order_xy = [eval(xy) for xy in order_str] order_xy_routine.append(order_xy) words_order_list[{}_{}.format(words_cnt, target_words[words_cnt])] = order_xy_routine words_cnt += 1 setting() # 畫布、畫筆設置 right_shift = 0 down_shift = 0 for k, v in words_order_list.items(): for lines in v: pu() for xy in lines: x, y = xy x, y = x * 0.2 - 400 + right_shift * 200, -y * 0.2 + 250 - down_shift * 200 goto(x, y) pd() right_shift += 1 if right_shift % 4 == 0: down_shift += 1 right_shift = 0 done()
筆順來自網路,可能有誤!代碼中可以找到該網站。
另外新人求贊!求贊!求贊!
可以呀,調用write函數。
不只是可以寫,還可以選擇字體類型,對齊方式等等
可以寫文本
※python2和python3到底選誰?※Python Requests庫使用指南※[數據結構]插入排序-Python※Python異常處理與程序調試※理解ROC(受試者工作特徵)曲線以及AUC
TAG:Python |