要輸出一個警告消息,可使用warning.warn()函數(shù)。例如: 1 2 3 4 5 6 importwarnings deffunc(x, y, logfile=None, debug=False): iflogfileisnotNone: warnings.warn('logfile argument deprecated', DeprecationWarning) ... warn()的參數(shù)是一個警告消息和一個警告類,警告類有如下幾種:UserWarning, Deprecatio...
www.dbjr.com.cn/article/1921...htm 2025-6-8