修改字符串,可以使用 io.String
s = 'hello,sxt'
import io
sio = io.StringIO(s)
sio
补前两章作业:
使用海龟绘图,输出四个矩形:
import turtle
turtle.width(5)
turtle.color("red")
turtle.goto(50,0)
turtle.goto(50,50)
turtle.goto(0,50)
turtle.goto(0,0)
turtle.penup()
turtle.goto(100,0)
turtle.pendown()
turtle.goto(150,0)
turtle.goto(150,50)
turtle.goto(100,50)
turtle.goto(100,0)
turtle.penup()
turtle.goto(0,-50)
turtle.pendown()
turtle.goto(50,-50)
turtle.goto(50,-100)
turtle.goto(0,-100)
turtle.goto(0,-50)
turtle.penup()
turtle.goto(100,-50)
turtle.pendown()
turtle.goto(150,-50)
turtle.goto(150,-100)
turtle.goto(100,-100)
turtle.