python turtle库打印文字
时间: 2023-09-27 22:11:48 浏览: 351
Python的turtle库可以通过使用turtle.write函数来打印文字。该函数用于在turtle界面上直接输出汉字,没有移动的轨迹。可以通过指定起始位置和目标汉字来打印单个汉字。例如,可以使用以下代码来打印汉字:
```python
import turtle
def writeWord(target_word, startx, starty):
turtle.color("black", "black")
turtle.pu()
turtle.goto(startx, starty)
turtle.pd()
turtle.write(target_word, move=False, align='left', font=('汉仪程行简', 120, 'normal'))
writeWord("你好", 0, 0)
turtle.done()
```
另外,如果想要在turtle界面上画出汉字的笔画轨迹,可以使用draw_words函数。该函数根据汉字的笔画坐标信息,绘制汉字的轨迹。
```python
import turtle
def draw_words(target_words, startx, starty, lineNum=1):
turtle.color("black", "black")
turtle.pu()
coordinates = obtain_coordinate(target_words)
for index, coordinate in enumerate(coordinates):
turtle.goto((startx + coordinate
阅读全文
相关推荐


















