gpt4 book ai didi

python - 在 python 脚本中隐藏导入时的警告消息

转载 作者:行者123 更新时间:2023-12-01 01:55:26 26 4
gpt4 key购买 nike

我想在python脚本中导入pydicom。因此,我使用以下命令来执行此操作,而不会出现任何警告消息:

import sys, warnings
if not sys.warnoptions:
warnings.simplefilter("ignore")
try:
import pydicom as dicom
except ImportError:
import dicom

但是我收到以下警告消息!!!!

/Users/anaconda3/lib/python3.6/site-packages/dicom/__init__.py:53: UserWarning: 
This code is using an older version of pydicom, which is no longer
maintained as of Jan 2017. You can access the new pydicom features and API
by installing `pydicom` from PyPI.
See 'Transitioning to pydicom 1.x' section at pydicom.readthedocs.org
for more information.
warnings.warn(msg)
/Users/anaconda3/lib/python3.6/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
from ._conv import register_converters as _register_converters

如何隐藏它?

最佳答案

也许 -> python -W 忽略 archive.py

选项 -W 跳过警告

关于python - 在 python 脚本中隐藏导入时的警告消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50262629/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com