Skip to content

Commit

Permalink
io module to simulate files
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel2409 committed Apr 2, 2021
1 parent 5a371c7 commit 24026c9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
22 changes: 22 additions & 0 deletions c5_06_io_op_on_strings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#%%
"""
feed a text or binary string to code that was written to handle file objects
"""
#%%
import io
s = io.StringIO()
s.write("Hello world")
print("myjam", file=s)
# %%
s.getvalue()
# %%
t = io.StringIO("Second test")
# %%
t.read(3)
# %%
t.read()
# %%
b = io.BytesIO()
b.write(b"Binary data")
b.getvalue()
# %%
1 change: 1 addition & 0 deletions jambon.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
myjam

0 comments on commit 24026c9

Please sign in to comment.