简体   繁体   English

如何让海龟在以下条件下接受用户输入?

[英]How can I make the turtle take user input in the following condition?

I am new at python.我是python的新手。 So, I recently started to code a game in python turtle in which different colored boxes would show up one at a time, and the user simply has to input the name of that color and then another color appears.所以,我最近开始用 python 龟编写一个游戏,其中一次显示一个不同颜色的框,用户只需输入该颜色的名称,然后另一种颜色就会出现。 For example, user has to input "Y" when yellow box appears.例如,当黄色框出现时,用户必须输入“Y”。 How do I code for this input?我如何为这个输入编码? Will this input be taken on turtle screen or the IDLE screen?这个输入是在海龟屏幕上还是在空闲屏幕上?

Use this for the input:将此用于输入:

color = input("What is the color of the box? ")

Then the color is saved under the variable 'color' when the user inputs the color in the shell.然后,当用户在 shell 中输入颜色时,颜色会保存在变量 'color' 下。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM