Code changes from Python 2.6 to 3.x

前端 未结 3 1338
广开言路
广开言路 2021-01-26 06:45

I am trying to get pywbem working in Python 3.2 (it works fine in 2.6) but the build fails on this part of code in mof_compiler.py:

  File \"pywbem-0.7.0\\mof_co         


        
3条回答
  •  花落未央
    2021-01-26 07:41

    One of the most visible changes in python 3 is print is no longer a statement, but is a function, so you have to use parenthesis for calling that function. print(s)

    Also, if you have your Python2 code, just use 2to3 which can do a source to source translation of your python2 to python3, which can fix most of the syntax level changes for you like the above problems. 2to3 is installed with python3 binary.

提交回复
热议问题