【问题标题】:How can I put a user input option in an if statement (Python/HTML)如何将用户输入选项放在 if 语句中(Python/HTML)
【发布时间】:2014-09-24 09:56:04
【问题描述】:

我正在为一个网站制作一个表格,如果用户选择它,我必须将礼品包装添加到最终成本中。 选中 = form.getvalue("giftwrap")

我试过了:

elif total > 150 and (b1 == "BC" or b1 == "bc" or b1 == "Bc" or b1 == "bC") and checked:
    print "<p>Tax: $",tax3,"</p>"

我也试过了:

elif total > 150 and (b1 == "BC" or b1 == "bc" or b1 == "Bc" or b1 == "bC") and
form.getvalue("giftwrap"):
    print "<p>Tax: $",tax3,"</p>"

它们似乎都不起作用。有什么帮助吗?谢谢。

【问题讨论】:

  • 究竟是什么不起作用?
  • 投反对票,问题没有显示任何研究工作并且不清楚..
  • 这是我的税 3 公式:tax3 = ((total-disc)+giftwrp)*0.12。我没有得到正确的答案,所以我假设它不起作用。
  • 绝对使用 bc.lower = "bc" 而不是检查所有可能的大小写。您的 b1 字段还包括换行符吗?在我们为您提供帮助之前,还有很多调试工作要做。

标签: python html forms


【解决方案1】:

打印你的条件:

print total > 150, b1.lower() == 'bc', checked

如果打印 True True True 那么它可以工作。如果至少有一个条件为 False:首先检查此条件。如果输出为静默,则 elif 不起作用(某些 'if' 之前为 True)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-02-16
    • 2020-09-17
    • 2014-01-02
    • 1970-01-01
    • 2013-02-27
    • 2013-03-25
    • 2023-04-02
    • 1970-01-01
    相关资源
    最近更新 更多