0

我想使用这个argparse问题的答案在命令行选项的描述中为用户提供支持的文件格式列表。但是,这需要运行plt.gcf(),它将打开一个 matplotlib 窗口。我想抑制这一点,只需plt.gcf().canvas.get_supported_filetypes()从不打开窗口的情况下获取字典。是否可以防止plt.gcf()打开新窗口?

代码:

import argparse
import matplotlib.pyplot as plt

options = str(list(plt.gcf().canvas.get_supported_filetypes().keys()))

parser = argparse.ArgumentParser()
parser.add_argument('-ext',help='Specify the file type. Options: {}'.format(options))
args = parser.parse_args()
4

0 回答 0