Closed 。这个问题需要细节或清晰度 /help/closed-questions 。目前不接受答案。
from turtle import Turtle, Screen
timmy_the_turtle = Turtle()
timmy_the_turtle.shape("turtle")
screen = Screen()
screen.exitonclick()
print("Hi")
当我运行这个时,我得到这个输出:
2023-06-18 13:08:23.720 Python[71369:2018591] WARNING: Secure coding is not enabled for restorable state! Enable secure coding by implementing NSApplicationDelegate.applicationSupportsSecureRestorableState: and returning YES.
我该怎么办?
我期待打印 hi,但什么也没发生。
您提到的消息“警告:未为可恢复状态启用安全编码!通过实现 NSApplicationDelegate.applicationSupportsSecureRestorableState: 并返回 YES 来启用安全编码”似乎与 macOS 特定功能相关,并且不会影响代码的执行。
关于不打印“Hi”的问题,问题出在你的代码顺序上。您在打印“Hi”之前调用 screen.exitonclick(),因此程序会立即退出,而不会给您机会看到输出。
要解决此问题,您可以按如下方式重新排序代码:
from turtle import Turtle, Screen
timmy_the_turtle = Turtle()
timmy_the_turtle.shape("turtle")
print("Hi")
screen = Screen()
screen.exitonclick()
通过此更改,应在程序退出之前打印输出“Hi”。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)