Python 2到3的转换:';TypeError:缺少必需的位置参数:';

Python 2到3的转换:';TypeError:缺少必需的位置参数:';,python,python-3.x,python-2to3,Python,Python 3.x,Python 2to3,我不熟悉Python(和stackoverflow),我的第一个任务是将能量流模拟程序从Python 2.7转换为Python 3.6,并在3.6上运行。我已经使用了2to3转换器并解决了一些其他错误,但现在我遇到了这个错误,不知道这是现有程序的错误还是使用了错误的语法等等。代码显然在Python 2中工作。 如果我在函数中额外输入house_atrs,它将启动函数,但会抛出一长串其他错误。因此,我希望得到您的帮助,并希望了解与2.7相比,3.6中出现此错误的原因 错误: Traceback (

我不熟悉Python(和stackoverflow),我的第一个任务是将能量流模拟程序从Python 2.7转换为Python 3.6,并在3.6上运行。我已经使用了2to3转换器并解决了一些其他错误,但现在我遇到了这个错误,不知道这是现有程序的错误还是使用了错误的语法等等。代码显然在Python 2中工作。 如果我在函数中额外输入house_atrs,它将启动函数,但会抛出一长串其他错误。因此,我希望得到您的帮助,并希望了解与2.7相比,3.6中出现此错误的原因

错误:

Traceback (most recent call last):
  File "D:\Users\hs\workspace\selfsuffbat\vpp_interface_refpool_noPCR_161026.py",
  line 85, in <module>
    analyze(sim_atrs, output_folder, output_subfolder, economic=True, binary=True)
TypeError: analyze() missing 1 required positional argument: 'output_subfolder'
[……]

main.py中函数analyze()的代码:

def analyze(sim_atrs, house_atrs, output_folder, output_subfolder, economic=True, economic_standalone=False, binary=False):
  print('started analyzing')
  analysis(folder=output_folder, subfolder=output_subfolder, fileindata=None, firstloop=True, binary=binary,
         usegreengrey=sim_atrs['use_greengrey'], usedegradation=sim_atrs['use_degradation'],
         uselocalbalance=sim_atrs['use_localbalance'], providePCR=sim_atrs['provide_pcr'],
         usethermal=sim_atrs['use_thermal_load'])
  if economic:
    assert economic_standalone is False, 'Set "economic" to False and "economic_standalone" to True for standalone calculations'
    economic_calc(output_folder, output_subfolder, year=2015, useselfsufficiency=sim_atrs['use_localbalance'])

  elif economic_standalone:
    assert economic is False, 'Set "economic" to True and "economic_standalone" to False for pooled calculations'
    economic_standalone_calc(output_folder, output_subfolder, year=2015, useselfsufficiency=sim_atrs['use_localbalance'])

  print('finished analyzing')

if __name__ == '__main__':
  pass

这个错误很有描述性。似乎需要将
house_atrs
作为第二个参数传递,这将使其成为4/4位置参数,您目前只通过了3/4。这个问题与Python3迁移无关——很明显,代码在Python2中也不起作用。不幸的是,您的编辑使这个问题变得非常不同,并且没有给出解决新问题的信息(作为错误消息)。我想知道,因为所有其他旧问题(2.7)在analyze()中,接口具有相同的代码行,没有house_atr。所以我更进一步,但我不知道这是否是有意的。无论如何,非常感谢你对初学者的帮助。
  simulate(house_atrs, sim_atrs, sim_args, output_folder, output_subfolder)
  analyze(sim_atrs, output_folder, output_subfolder, economic=True, binary=True)
def analyze(sim_atrs, house_atrs, output_folder, output_subfolder, economic=True, economic_standalone=False, binary=False):
  print('started analyzing')
  analysis(folder=output_folder, subfolder=output_subfolder, fileindata=None, firstloop=True, binary=binary,
         usegreengrey=sim_atrs['use_greengrey'], usedegradation=sim_atrs['use_degradation'],
         uselocalbalance=sim_atrs['use_localbalance'], providePCR=sim_atrs['provide_pcr'],
         usethermal=sim_atrs['use_thermal_load'])
  if economic:
    assert economic_standalone is False, 'Set "economic" to False and "economic_standalone" to True for standalone calculations'
    economic_calc(output_folder, output_subfolder, year=2015, useselfsufficiency=sim_atrs['use_localbalance'])

  elif economic_standalone:
    assert economic is False, 'Set "economic" to True and "economic_standalone" to False for pooled calculations'
    economic_standalone_calc(output_folder, output_subfolder, year=2015, useselfsufficiency=sim_atrs['use_localbalance'])

  print('finished analyzing')

if __name__ == '__main__':
  pass