0

我是 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
4

0 回答 0