Python 关闭web.py中db.update的输出

Python 关闭web.py中db.update的输出,python,database,web.py,Python,Database,Web.py,我正在使用web.py对数据库进行抽象处理。我循环浏览一系列网页,搜集相关信息,并将其编入文章。然后我更新了数据库中的一个列来保存这篇文章 for update_number in range(len(user_list)): db.update('users',where="username = '%(user)s'"%{"user":username},essay_data=compiled_essay) 问题是,这最终会在我使用的python shell中打印出db命令

我正在使用web.py对数据库进行抽象处理。我循环浏览一系列网页,搜集相关信息,并将其编入文章。然后我更新了数据库中的一个列来保存这篇文章

for update_number in range(len(user_list)):    
    db.update('users',where="username = '%(user)s'"%{"user":username},essay_data=compiled_essay) 
问题是,这最终会在我使用的python shell中打印出db命令:

0.0 (update_number): UPDATE users SET essay_data = 'lots_of_text' WHERE username = 'the_user'

我的问题是如何使db.update命令静音,使其不会在每次更新时打印大量文本。

因为您是在Python shell中执行此操作的,一种方法是将输出设置为变量:

for update_number in range(len(user_list)):    
    x = db.update('users',where="username = '%(user)s'"%{"user":username},essay_data=compiled_essay) 

由于您是在Python shell中执行此操作,一种方法是将输出设置为变量:

for update_number in range(len(user_list)):    
    x = db.update('users',where="username = '%(user)s'"%{"user":username},essay_data=compiled_essay) 

根据注释中的建议,标志
\u test=True
使输出静音

db.update('users',where="username = '%(user)s'"%{"user":username},essay_data=compiled_essay,_test=True) 

根据注释中的建议,标志
\u test=True
使输出静音

db.update('users',where="username = '%(user)s'"%{"user":username},essay_data=compiled_essay,_test=True) 

打印仅在开发模式下启用

在创建db之前,可以通过添加以下行来显式禁用它

web.config.debug = False
或者,通过设置:

db.printing = False

打印仅在开发模式下启用

在创建db之前,可以通过添加以下行来显式禁用它

web.config.debug = False
或者,通过设置:

db.printing = False

web.config.debug=False仍然没有帮助。还有一些事情要做

注释掉文件中的行: C:\Python27\Lib\site packages\web\httpserver.py

行:


web.config.debug=False仍然没有帮助。还有一些事情要做

注释掉文件中的行: C:\Python27\Lib\site packages\web\httpserver.py

行:


没有骰子,我得到的输出基本相同。x最后保存了一个int。我相信这是一个成功的代码。那么您使用的模块必须自己打印这个输出,您可以给这个模块一个类似debug=False的参数吗?标志是_test=True。谢谢你让我走上正轨。不用说,我得到的输出基本相同。x最后保存了一个int。我相信这是一个成功的代码。那么您使用的模块必须自己打印这个输出,您可以给这个模块一个类似debug=False的参数吗?标志是_test=True。谢谢你让我走上正轨。