升级webpy库

 最近将以前的一个webpy程序对其所依赖的webpy库从0.23升级到了最新的0.36,这里做个简单的总结:

1)老版本中GET POST函数中使用print函数向客户端输出内容,新版本用return 语句代替了print,即函数返回的字符串就是向客户端的输出内容;

简单的替换过程中也得注意到程序控制流可能因为return而提前终止了。

2)web.input()默认返回的是unicode字符,一般替换掉web.input函数的实现

1     # from 3.0 web.input() use unicode default, we replace it
2     tmp_input = web.input
3     def orig_input(*requireds, **defaults):
4         defaults["_unicode"] = False
5         return tmp_input(*requireds, **defaults)
6     web.input = orig_input
更详尽的注意事项可参见官方文档 http://webpy.org/docs/0.3/upgrade
原文地址:https://www.cnblogs.com/JesseFang/p/2385317.html