如何主动产生warning错误:
import
warnings
def
fxn():
warnings.warn(
"deprecated"
, DeprecationWarning)
with warnings.catch_warnings():
warnings.simplefilter(
"ignore"
)
fxn()
import
warnings
warnings.filterwarnings(
"ignore"
)
如何忽略命令行下警告错误的输出呢?
python -W ignore yourscript.py
那么如何忽略全部的异常呢?下面是一个事例
import pandas as pd
dates=range(20161010,20161114)
pieces=[]
for date in dates:
try:
data=pd.read_csv(\'A_stock/overview-push-%d/stock overview.csv\' %date, encoding=\'gbk\')
pieces.append(data)
except Exception as e:
pass
continue
data=pd.concat(pieces)
参考:
https://www.cnblogs.com/blueel/p/3529517.html
https://blog.csdn.net/weixin_43307577/article/details/87710251