import io
a = "test txt"
sio = io.StringIO(a)
print(sio.getvalue())
sio.seek(4)
sio.write("abc")
print(sio.getvalue())
結果:
test txt
testabct
import io
a = "test txt"
sio = io.StringIO(a)
print(sio.getvalue())
sio.seek(4)
sio.write("abc")
print(sio.getvalue())
結果:
test txt
testabct
1.while循環的格式 while 條件: 條件滿足時,做的事情1 條件滿足時,做的事情2 條件滿足時,做的事情3 ...(省略)... demo