在使用蒂夫时,我一直收到以下警告。我发现它很好,但我一直给出这些警告,我想加以压制。
TIFFFetchNormalTag: Warning, ASCII value for tag "DateTime" contains null byte in value; value incorrectly truncated during reading due to implementation limitations.
我使用它的方式如下:
string = tf.io.read_file(filename)
image = tfio.experimental.image.decode_tiff(string) # this line produces warning如果我试图使用warning来抑制警告,它似乎不起作用吗?它没有给我一个错误,但它什么也没做。
import warnings
warnings.filterwarnings('ignore', message='ASCII value for tag "DateTime" contains null byte in value; value incorrectly truncated during reading due to implementation limitations')如何抑制此警告,或解决产生此警告的问题?
发布于 2021-05-11 16:03:40
如果你想压制所有的警告,那么你可以使用
warnings.filterwarnings("ignore")如果想抑制某些消息,那么您必须在消息开始时使用message=...,或者在开始时使用.*。
warnings.filterwarnings("ignore", message=".*ASCII value for tag")最起码的例子:
import warnings
warnings.filterwarnings("ignore", message=".*ASCII value for tag")
# some tests - it should be supressed by `filterwarnings()`
warnings.warn('TIFFFetchNormalTag: Warning, ASCII value for tag "DateTime" contains null byte in value; value incorrectly truncated during reading due to implementation limitations.')
print("Hello World")https://stackoverflow.com/questions/67481782
复制相似问题