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