第3步:要运行一个函数,我们必须通过使用它的名字来调用该函数。

调用函数的指令不应该缩进,因为它与函数是分开的。

  • 点击 运行。注意,这个函数代码位于编辑器中,但是不在控制台上运行。
  • 点击 ,将 Function Call 拖动到程序底端的函数外部。
  • my_function() 更改为 park_scene()。点击 运行 以在控制台上查看你的函数。

To navigate the page using the TAB key, first press ESC to exit the code editor.

sprite = codesters.Sprite("knight1", -175, -150) sprite.set_speed(2) def park_scene(): stage.set_background("park") sprite.say("I should hurry to the castle!") sprite.move_forward(550)
  • Run Code
  • 提交作品
  • 下个活动
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)