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

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -