用龟蟒画“DBGS”

2024-10-02 18:24:06 发布

您现在位置:Python中文网/ 问答频道 /正文

我在尝试用turtle python编写代码时遇到了困难。我需要帮忙画字母“D”。但我的目标是画“DBGS”这个字母。指的是我学校的缩写。请帮忙


Tags: 代码目标字母学校turtledbgs
1条回答
网友
1楼 · 发布于 2024-10-02 18:24:06

如果您想实际绘制它们,请参见this question获取一些提示和建议。否则,turtle有一个内置的文本方法^{}。参数如下:

turtle.write(*arg*, *move=False*, *align="left"*, *font=("Arial", 8, "normal")*)
Parameters:

  • arg – object to be written to the TurtleScreen
  • move – True/False
  • align – one of the strings “left”, “center” or right”
  • font – a triple (fontname, fontsize, fonttype)

例如:

turtle.write('DBGS', #the text
             True, #move the mouse to the bottom left corner of the text
             'center', #align the text to centre
             ('Arial', 10, 'bold')) #'Arial' font, size 10, bold

画“D”的一种简单方法是用半圆:

^{pr2}$

相关问题 更多 >