1
我最近一直在玩Twill和BeautifulSoup來做一些基本的屏幕掃描。但是,看來我正在使用的一個命令是在屏幕上打印一堆不需要的輸出。下面的代碼的快速片斷我用來登錄到網站的問題:優雅地抑制Python中的斜紋輸出
from twill.commands import *
from twill import get_browser
mybrowser = get_browser()
mybrowser.go(url)
mybrowser.showforms()
formvalue('1', 'email', email)
formvalue('1', 'password', password)
mybrowser.submit()
result = show()
目前,我使用的是「redirect_output()」功能來管不需要輸出到garbage-填充文本文件...但這似乎是一個非常黑客的解決方案。使用上面的命令有沒有更好的方法來避免過度打印?
+1從薩拉托夫:) – alecxe
不知道os.devnull直到現在......非常酷。非常感謝! –