瓶中的原始输入模拟

时间:2013-06-23 04:47:01

标签: python python-2.7 bottle

我无法弄清楚如何在Bottle框架中创建raw_input()。

for idx, d in enumerate(student):
        for ids, s in enumerate(student):
            if d['Name'] == s['Name'] and idx != ids:
                print d,idx
                l=raw_input('input number to delete')
                student.pop(int(l))
    for m in student:
    for k in olympiad:
      if m['Name']==k['Name']:
                this.append(k)

如果我返回模板而不是raw_input(),我将丢失所有其他操作。我不想在控制台中写这个动作。

1 个答案:

答案 0 :(得分:1)

Bottle是一个Web框架,因此它的所有输入和输出都是通过Web服务器完成的。这意味着如果Web服务器甚至有标准输入,它肯定没有连接到任何Web浏览器,因此在Bottle WSGI环境中raw_input没有用。

在WSGI下获取用户输入的最常用方法是通过POST浏览器请求。为此,您应该了解Bottle forms