Q:

opening file odd error in python 3

i have a quick question so im trying to code up something in python to open up a file and im getting a weird error when i run it ill post the error below with my code included, but ive never seen it before and im not sure what it means. if anyone has any ideas id really appreciate it. thanks !
code
def readfile():
    filename = input(str("What is the files name you would like to import "))
    f = open(filename)
    for line in f:
        print(line)

error

builtins.UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in
  position 32: ordinal not in range(128)

A:

This is an encoding mismatch - you are trying to read the file in ASCII (which Python has detected from your operating system settings), when it is encoded in something else. You can specify an encoding when you open it:
f = open(filename, encoding='utf-8')

UTF-8 might not be the right encoding here either, but if you expect the file to contain mostly English words, it is probably a good guess. Ideally, you should try to find out the encoding of the file another way if you can - checking the settings of any program that successfully opens it can help, or if you're on a Unix-like system, the file command might tell you. 

