「WB」モードはそう「」bが正しく書き込むことができる前に、バイナリ入力されるので、そうでない場合、エラーが存在するであろう。
TypeError: a bytes-like object is required, not 'str'
環境のpython 3.6
f = open('test.txt', 'wb')
for i in range(3):
f.write(b'hello python\n')
f.close()
「WB」モードはそう「」bが正しく書き込むことができる前に、バイナリ入力されるので、そうでない場合、エラーが存在するであろう。
TypeError: a bytes-like object is required, not 'str'
環境のpython 3.6
f = open('test.txt', 'wb')
for i in range(3):
f.write(b'hello python\n')
f.close()