2024-04-19 12:27:39 发布
网友
我必须在学校做编码工作。我应该随机列出几个数字,完成海龟在上面移动的动作。我想知道如何列出海龟窗口中输入的数字。有可能吗?你知道吗
如果要输入文本,则需要turtle.write():
turtle.write()
import random a = [random.randint(0,10) for x in range(10)] # Generate 10 random numbers between 0 and 10 for i in a: turtle.forward(15) turtle.write(str(i))
你需要移动海龟,否则所有的数字都会出现在彼此的上面。你知道吗
有关turtle.write()的信息,请参见Python Turtle, draw text with on screen with larger font和documentation
您可以使用write
write
import turtle if __name__ == '__main__': number = 42 t = turtle.Turtle() t.write(number) turtle.done()
如果要输入文本,则需要
turtle.write()
:你需要移动海龟,否则所有的数字都会出现在彼此的上面。你知道吗
有关
turtle.write()
的信息,请参见Python Turtle, draw text with on screen with larger font和documentation您可以使用
write
相关问题 更多 >
编程相关推荐