Automated Python translation 2to3 error -


i want translate python2 code python 3.it simple,but not work

import sys import mysqldb import cookbook  try:  conn = cookbook.connect () print "connected"  except mysqldb.error, e:  print "cannot connect server"  print "error code:", e.args[0]  print "error message:", e.args[1]  sys.exit (1)  conn.close () print "disconnected" 

i got in terminal

2to3 harness.py refactoringtool: skipping optional fixer: buffer refactoringtool: skipping optional fixer: idioms refactoringtool: skipping optional fixer: set_literal refactoringtool: skipping optional fixer: ws_comma refactoringtool: can't parse harness.py: parseerror: bad input: type=1, value='print', context=('', (9, 0)) refactoringtool: no files need modified. refactoringtool: there 1 error: refactoringtool: can't parse harness.py: parseerror: bad input: type=1, value='print', context=('', (9, 0)) 

why?

don't know if solve problem, try fixing indentation:

import sys import mysqldb import cookbook  try:     conn = cookbook.connect ()     print "connected" except mysqldb.error, e:     print "cannot connect server"     print "error code:", e.args[0]     print "error message:", e.args[1]     sys.exit (1)  conn.close () print "disconnected" 

Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -