import Tkinter
if __name__ == '__main__':
from Tkinter import *
root = Tk()
root.title('Canvas')
canvas = Canvas(root, width=400, height=400, bg='yellow')
x0 = 200
y0 = 200
y1 = 200
x1 = 200
for i in range(5):
canvas.create_rectangle(x0, y0, x1, y1)
canvas.create_oval(x0, y0, x1, y1)
x0 -= 20
y0 -= 10
x1 += 10
y1 += 10
canvas.pack()
root.mainloop()
注意import Tkinter,大小写
注意缩进,一般都不会出现错误