Forums

Why must I use a bytes-like object, this code works elsewhere.

TypeError Traceback (most recent call last) ~/output_folder/Create_page_variables.py in <module> 8 </html>""" 9 ---> 10 f.write(message) 11 f.close()

TypeError: a bytes-like object is required, not 'str'

I am trying to create a simple "Hello World" html page. The python script is from a tutorial and validates at pep8online.com. I ran it on my MacBook without a problem. I was going to skip this step and just use a template from Django, Flask or Bottle but i wanted this to work first.

that sounds like you were running one one platform with python2, and another platform with python3