This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2012年08月14日 05:03 by umedoblock, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Messages (3) | |||
|---|---|---|---|
| msg168174 - (view) | Author: umedoblock (umedoblock) | Date: 2012年08月14日 05:03 | |
import io _bytesio = io.BytesIO() _bytesio.write(b'abc') _bytesio.write(b'def') _bytesio.seek(0) _bytesio.write(b'xyz') print(_bytesio.read(2)) print(_bytesio.read(2)) print(_bytesio.getvalue()) # output b'de' b'f' b'xyzdef' # where is the b'abc' ? |
|||
| msg168177 - (view) | Author: Ned Deily (ned.deily) * (Python committer) | Date: 2012年08月14日 06:36 | |
The program works as expected. After the first two writes, the buffer contains b'abcdef'. Then the seek(0) moves the stream pointer to the beginning of the buffer and the next write overwrites buffer positions 0 through 2, replacing b'abc' with b'xyz'. So now the buffer is b'xyzdef'. The next read starts at position 3 (following the last byte written), reading b'de'. |
|||
| msg168201 - (view) | Author: umedoblock (umedoblock) | Date: 2012年08月14日 13:56 | |
thanks Ned. I understood your comment. I'm happy! |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:34 | admin | set | github: 59849 |
| 2012年08月14日 13:56:53 | umedoblock | set | messages: + msg168201 |
| 2012年08月14日 06:36:51 | ned.deily | set | status: open -> closed type: behavior -> nosy: + ned.deily messages: + msg168177 resolution: works for me stage: resolved |
| 2012年08月14日 05:03:30 | umedoblock | create | |