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

时间:2018-05-25 12:00:09

标签: python python-3.x python-2to3

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

错误:

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'

vpp_interface_refpool_noPCR161026.py的代码:

from pool_builder import pool_df
from main import simulate
from main import analyze    

if __name__ == '__main__':

  output_folder = 'output/data/'
  output_subfolder = 'refpool_noPCR'

[...]

  simulate(house_atrs, sim_atrs, sim_args, output_folder, output_subfolder)
  analyze(sim_atrs, output_folder, output_subfolder, economic=True, binary=True)

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

0 个答案:

没有答案