0

这是我用来为 microbit 创建 Edice 的代码: from microbit import * import random image1 = Image("00000:" "00000:" "00900:" "00000:" "00000") image2 = Image("90000: " "00000:" "00000:" "00000:" "00009") image3 = Image("90000:" "00000:" "00900:" "00000:" "00009") image4 = Image("90009:" 00000:" "00000:" "00000:" "90009") image5 = Image("90009:" "00000:" "00900:" "00000:" "90009") image6 = Image("90009:" "00000:" "90009:" "00000:" "90009") images=[image1, image2, image3, image4, image5, image6]

while True: if button_a.is_pressed(): for i in range(0, 16):

        display.show(images)
        display.show(random.randint.(1, 6))
        sleep(20)
        display.clear
    display.show(image(random.randint(1, 6)))

display.show(random.randint.(1, 6)) 似乎被注册为语法错误。我可以知道问题出在哪里以及如何改进代码

4

1 回答 1

1

有一个额外的.

你写道: display.show(random.randint.(1, 6))
它应该是: display.show(random.randint(1, 6))

于 2020-01-21T11:04:08.697 回答