laciel拉希尔 2021-05-24 11:15 采纳率: 100%
浏览 46
已结题

flask前后交互,python?

if __name__ == '__main__':
    with open('commandcode.json') as commandcode:
        head_baowen = json.load(commandcode)
        running_head_baowen = head_baowen["total_baowen_head"]["running_state_data"]
        operation_head_baowen = head_baowen["total_baowen_head"]["operation_move"]
        data_baowen = head_baowen["total_baowen_head"]["data_baowen"]
        addr = (head_baowen['addr']['addr1'][0], head_baowen['addr']['addr1'][1])

    app.run(debug=True, host='127.0.0.1', port=8000)


@app.route("/suspend", methods=["POST"])
def web_command_suspend():
    b = operation_type('2', message_add(data_baowen))
    send_move_command(operation_head_baowen, b, addr)

    return {"msg": "suspend"}


 

 

错误:

Traceback (most recent call last):
  File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python38\Lib\site-packages\flask\app.py", line 2069, in __call__
    return self.wsgi_app(environ, start_response)
  File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python38\Lib\site-packages\flask\app.py", line 2054, in wsgi_app
    response = self.handle_exception(e)
  File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python38\Lib\site-packages\flask\app.py", line 2051, in wsgi_app
    response = self.full_dispatch_request()
  File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python38\Lib\site-packages\flask\app.py", line 1501, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python38\Lib\site-packages\flask\app.py", line 1499, in full_dispatch_request
    rv = self.dispatch_request()
  File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python38\Lib\site-packages\flask\app.py", line 1485, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "D:\work\KC\html_test.py", line 94, in web_command_suspend
    send_move_command(operation_head_baowen, b, addr)
TypeError: send_move_command() missing 1 required positional argument: 'addr'

send_move_command()只有3个参数位置

错误提示是缺少addr的位置,没有设置self,这种情况是一定要写个类的实例才行吗?

 

  • 写回答

5条回答 默认 最新

  • 关注

    错误提示是缺少addr的位置,原因是没有对类进行实例化。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

问题事件

  • 系统已结题 6月16日
  • 已采纳回答 6月8日

悬赏问题

  • ¥15 状态机/汽车转向灯/Sateflow
  • ¥15 这个有点复杂 有没有人看看
  • ¥15 用python如何确定子孙元素在父元素中的位置
  • ¥15 obj文件滤除异常高程
  • ¥15 用mathematicas或者matlab计算三重积分
  • ¥15 Loop unrolling的runtime计算
  • ¥100 NVMe-oF的Target端,开启attr_offload后,测试失败。
  • ¥100 有偿照片马赛克去掉,保留原始数据
  • ¥15 c# winform http报错,如何解决?
  • ¥15 统计软件及应用-r软件