Tag Archives: Python3.x

Python3.x Error:AttributeError: ‘str’ object has no attribute ‘decode’

Python 3. X: attributeerror: ‘STR’ object has no attribute ‘decode’

1. There are some differences between Python 3.X and python 2.X. I encountered two problems as follows:

a. First report: mysqlclient version 1.3 is wrong:

Solution: comment out the line

b. Second, the problem of character set

The error is as follows: file “C:// users/administrator/pcharmprojects/untitled1/venv/lib/site packages/Django/db/backends/MySQL/operations. Py”, line 146, in last_ executed_ query

query = query.decode(errors=’replace’)

AttributeError: ‘str’ object has no attribute ‘decode’

Solution: Comment out here because the character set is not supported

Python3.x Run Python2.x Codes syntax error: “Missing parentheses in call to ‘print’

#Another type of error
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(

The format of the code is as follows:

print "File %s not exist" % filename
。。。
print '-------xxx------'

change to 
print ("File %s not exist" % filename)
print ('-------xxx------')

Link: https://stackoverflow.com/questions/41341149/python-3-6-0-syntax-error-missing-parentheses-in-call-to-print?noredirect=1&lq=1