What do I need do to make sure the data is read as binary and not text when i do
cat binfile | myscript.py
reads as text mode I need binary mode?
data = sys.stdin.read
What do I need do to make sure the data is read as binary and not text when i do
cat binfile | myscript.py
reads as text mode I need binary mode?
data = sys.stdin.read
Assuming you're using the latest version of Python, that you're looking for is:
sys.stdin.buffer.read()
Note: You must use help(sys.__stdin__)
in interactive mode. This is because you can't use the normal stdin
in interactive mode. sys.stdin.buffer
simply doesn't exist in interactive mode.