python write string directly to tarfile

后端 未结 7 1292
-上瘾入骨i
-上瘾入骨i 2020-12-08 13:28

Is there a way to write a string directly to a tarfile? From http://docs.python.org/library/tarfile.html it looks like only files already written to the file system can be a

7条回答
  •  不知归路
    2020-12-08 14:02

    Just for the record:
    StringIO objects have a .len property.
    No need to seek(0) and do len(foo.buf)
    No need to keep the entire string around to do len() on, or God forbid, do the accounting yourself.

    ( Maybe it did not at the time the OP was written. )

提交回复
热议问题