我想使用乌龟功能写出我输入的内容

发布于 2025-01-22 19:55:55 字数 164 浏览 0 评论 0原文

我已经制作了一根乌龟绳来制作aphabet中的每个字母,并将它们分配给函数,因此我只需要打印一个()才能写出一个A。但是,我想知道的是,是否可以让用户输入句子或单词,然后搜索输入并找到所有使用的字母,然后打印那些相应的功能,以打印输入中所述的内容。我不知道这是否可能是可能的,但是如果是,我想知道如何。 先感谢您。

i have already made a turtle string to make every letter in the aphabet, and assigned them to functions, so i only have to print a() for it to write out an A for example. but what im wondering is if it is possible to have the user input a sentence or word, and then search through the input and find all letters used, then print those corresponding functions, to print out what is said in the input. i have no idea if this is even possible, but if it is i would like to know how.
thank you in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

漆黑的白昼 2025-01-29 19:55:55

一个简单的方法是使用乌龟写功能。

import turtle
my_text = input("type something: ")
turtle.write(my_text)
turtle.done()

Turtle.done()在乌龟运行后可见可见。

如果您想为每个字母使用单独的功能,则需要将输入分为字母,并将其调用如评论中提到的函数。此方法称为调度表。请编辑您的问题,以显示您到目前为止尝试的尝试。

An easier way to do this is to use the turtle write function.

import turtle
my_text = input("type something: ")
turtle.write(my_text)
turtle.done()

turtle.done() is there to keep the turtle screen visible after it runs.

If you want to use a separate function for each letter you will need to split your input into letters and call the functions like was mentioned in the comments. This approach is called a dispatch table. Please edit your question to show what you have attempted so far.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文