|
比如tornado中计划要接受一个参数noexists,用下面的语句接受的:
noexists = self.request.arguments.get('name')[0] 但是由于某些原因,浏览器并没有把这个字段发出,那么程序这时候就会挂掉,我目前的做法是: try: noexists = self.request.arguments.get('name')[0] except TypeError, message: print message noexists = None 感觉这个方法比较笨,不知道有没有好点的做法? 来自: python-cn`CPyUG`华蟒用户组(中文Python技术邮件列表) 规则: http://code.google.com/p/cpyug/wiki/PythonCn 发言: [hidden email] 退订: [hidden email] (向此发空信即退!) 详情: http://code.google.com/p/cpyug/wiki/PythonCn 严正: 理解列表! 智慧提问! http://wiki.woodpecker.org.cn/moin/AskForHelp 强烈: 建议使用技巧: 如何有效地报告Bug http://www.chiark.greenend.org.uk/%7Esgtatham/bugs-cn.html |
|
noexists = self.request.argument.get('name', None)
2011/12/29 viders <[hidden email]> 比如tornado中计划要接受一个参数noexists,用下面的语句接受的: What can change the nature of a man?(Planescape Torment) ---------------------------------------------------------------------------------------- http://feilong.me Felinx Lee's Blog (Chinese Only) http://www.zhimaq.com IT Q&A (Chinese Only) http://poweredsites.org What powered your sites? PHP, Ruby or Python? -- 来自: python-cn`CPyUG`华蟒用户组(中文Python技术邮件列表) 规则: http://code.google.com/p/cpyug/wiki/PythonCn 发言: [hidden email] 退订: [hidden email] (向此发空信即退!) 详情: http://code.google.com/p/cpyug/wiki/PythonCn 严正: 理解列表! 智慧提问! http://wiki.woodpecker.org.cn/moin/AskForHelp 强烈: 建议使用技巧: 如何有效地报告Bug http://www.chiark.greenend.org.uk/%7Esgtatham/bugs-cn.html |
|
这跟tornado不搭嘎,是python基础问题...
http://docs.python.org/library/stdtypes.html#dict.get
-- 2011/12/29 Felinx Lee <[hidden email]> noexists = self.request.argument.get('name', None) Best regards, Forrest Liu 来自: python-cn`CPyUG`华蟒用户组(中文Python技术邮件列表) 规则: http://code.google.com/p/cpyug/wiki/PythonCn 发言: [hidden email] 退订: [hidden email] (向此发空信即退!) 详情: http://code.google.com/p/cpyug/wiki/PythonCn 严正: 理解列表! 智慧提问! http://wiki.woodpecker.org.cn/moin/AskForHelp 强烈: 建议使用技巧: 如何有效地报告Bug http://www.chiark.greenend.org.uk/%7Esgtatham/bugs-cn.html |
|
In reply to this post by Felinx Lee
补充下,也可以这样玩 noexists = self. get_argument('name', None)
2011/12/29 Felinx Lee <[hidden email]> noexists = self.request.arguments.get('name', None) What can change the nature of a man?(Planescape Torment) ---------------------------------------------------------------------------------------- http://feilong.me Felinx Lee's Blog (Chinese Only) http://www.zhimaq.com IT Q&A (Chinese Only) http://poweredsites.org What powered your sites? PHP, Ruby or Python? -- 来自: python-cn`CPyUG`华蟒用户组(中文Python技术邮件列表) 规则: http://code.google.com/p/cpyug/wiki/PythonCn 发言: [hidden email] 退订: [hidden email] (向此发空信即退!) 详情: http://code.google.com/p/cpyug/wiki/PythonCn 严正: 理解列表! 智慧提问! http://wiki.woodpecker.org.cn/moin/AskForHelp 强烈: 建议使用技巧: 如何有效地报告Bug http://www.chiark.greenend.org.uk/%7Esgtatham/bugs-cn.html |
|
get_argument和get_arguments貌似才是tornado的标准参数获取方法
2011/12/29 Felinx Lee <[hidden email]>
Best regards, Forrest Liu -- 来自: python-cn`CPyUG`华蟒用户组(中文Python技术邮件列表) 规则: http://code.google.com/p/cpyug/wiki/PythonCn 发言: [hidden email] 退订: [hidden email] (向此发空信即退!) 详情: http://code.google.com/p/cpyug/wiki/PythonCn 严正: 理解列表! 智慧提问! http://wiki.woodpecker.org.cn/moin/AskForHelp 强烈: 建议使用技巧: 如何有效地报告Bug http://www.chiark.greenend.org.uk/%7Esgtatham/bugs-cn.html |
|
noexists = self.request.arguments.get('name')
在 2011年12月29日 下午4:59,Forrest Liu <[hidden email]>写道: get_argument和get_arguments貌似才是tornado的标准参数获取方法 -- 来自: python-cn`CPyUG`华蟒用户组(中文Python技术邮件列表) 规则: http://code.google.com/p/cpyug/wiki/PythonCn 发言: [hidden email] 退订: [hidden email] (向此发空信即退!) 详情: http://code.google.com/p/cpyug/wiki/PythonCn 严正: 理解列表! 智慧提问! http://wiki.woodpecker.org.cn/moin/AskForHelp 强烈: 建议使用技巧: 如何有效地报告Bug http://www.chiark.greenend.org.uk/%7Esgtatham/bugs-cn.html |
| Powered by Nabble | See how NAML generates this page |
