日々精進

新しく学んだことを書き留めていきます

2016-10-06から1日間の記事一覧

io.BytesIOをstrに変換する

AI

self.contentがio.BytesIOオブジェクトとすると以下のようなコードで変換出来る。 def get_content_str(self) -> str: content_str: str = self.content.read().decode('UTF-8') self.content.seek(0) return content_str readするたびにseek(0)しないといけ…