如何在 python 中用乌龟写下一行

How to write in a next line with turtle in python

for i in range(0, len(all_keys)):
    if i == 4:
        break

    elem = dict1[all_keys[i]]

    output = elem + ": " + str(all_keys[i])

    print(output)

    write(output, font = style, align = "right")

    del dict1[all_keys[i]]

我如何才能做到 "for" 循环的每次迭代都在新行中写入,因为现在它是在彼此之上写入的。

一般需要使用turtle命令才能移动到下一行输出。具体需要将X坐标return左边缘,Y坐标下移字体高度:

from turtle import *

DICTIONARY = {'one': 'uno', 'two': 'dos', 'three': 'tres'}

FONT_SIZE = 24
STYLE = ('Arial', FONT_SIZE, 'normal')

penup()

for key, element in DICTIONARY.items():

    output = element + ': ' + key

    write(output, font=STYLE)

    goto(0, ycor() - FONT_SIZE)

mainloop()