UnicodeDecodeError, invalid continuation byte

前端 未结 10 2134
忘掉有多难
忘掉有多难 2020-11-22 08:25

Why is the below item failing? Why does it succeed with "latin-1" codec?

o = "a test of \\xe9 char" #I want this to remain a string as thi         


        
10条回答
  •  天涯浪人
    2020-11-22 09:02

    In this case, I tried to execute a .py which active a path/file.sql.

    My solution was to modify the codification of the file.sql to "UTF-8 without BOM" and it works!

    You can do it with Notepad++.

    i will leave a part of my code.

    /Code/

    con=psycopg2.connect(host = sys.argv[1], port = sys.argv[2],dbname = sys.argv[3],user = sys.argv[4], password = sys.argv[5])

    cursor = con.cursor() sqlfile = open(path, 'r')

提交回复
热议问题