o618
V2EX  ›  问与答

tornado 如何定义某个名字

  •  
  •   o618 · Feb 12, 2014 · 2775 views
    This topic created in 4484 days ago, the information mentioned may be changed or developed.
    定义了self.get_argument('reply_id'),但程序运行报错:Missing argument reply_id
    2 replies    1970-01-01 08:00:00 +08:00
    PotatoBrother
        1
    PotatoBrother  
       Feb 12, 2014   ❤️ 1
    1.确认handlers里有写url
    2.访问时访问正确的url
    mywaiting
        2
    mywaiting  
       Feb 12, 2014   ❤️ 1
    Tornado的web.py代码写得很清楚啊。默认情况下,没有提供默认参数给get_argument(),而且你的URL中没有包含这个参数的话,Tornado会报Missing argument

    用get_argument()的时候,最好传递默认值,像这样:

    reply_id = self.get_argument('reply_id', None)

    这样Tornado就不会报Missing argument
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5452 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 58ms · UTC 05:46 · PVG 13:46 · LAX 22:46 · JFK 01:46
    ♥ Do have faith in what you're doing.