main 函数不返回任何内容



我有一个由两个函数组成的python脚本tolist_converter和主

def tolist_converter(i_mass,i_vol,t_mass,t_vol,t_cost,p_id):
    # Item masses, volumes
    item_mass = i_mass.tolist()
    item_vol = i_vol.tolist()
    
    # Mass & volume capacities of trucks
    truck_mass = t_mass.tolist()
    truck_vol = t_vol.tolist()
    
    # Cost of using each truck
    truck_cost = t_cost.tolist()
    id_series = p_id
    
    return(item_mass,item_vol,truck_mass,truck_vol,truck_cost, id_series)

主要功能

def main(item_m,item_v,truck_m,truck_v,truck_c, id_s):
    item_mass,item_vol,truck_mass,truck_vol,truck_cost, id_series = tolist_converter(item_m,item_v,truck_m,truck_v,truck_c, id_s)
    return item_mass

我像这样调用主函数:

if __name__ == "__main__": 
    print("this function is running")
    main(data["Weight"],data["Volume"],truck["Weight"],truck["Volume"],truck["Price"],data["Pid"])

当我在终端中运行此主要功能时,它不会给我任何东西。根据我的理解,当调用main函数时,它应该在终端屏幕中返回item_mass

这是终端的输出

C:\Users\Sid\Downloads\aggregator-master\django_school\classroom\views>py Disp.py

此函数正在运行

尝试print main函数:

if __name__ == "__main__": 
    print("this function is running")
    print(main(data["Weight"],data["Volume"],truck["Weight"],truck["Volume"],truck["Price"],data["Pid"]))

相关内容

  • 没有找到相关文章

最新更新