首页 > 解决方案 > 在python中导入但未使用

问题描述

import bumpy as np
import matplotlib.pyplot as per
import pandas as pd.

控制台显示一些警告。谁能帮我这个

标签: pythonpyspider

解决方案


In python, when you import a library, it is expected to be utilized in the code blocks. Hence, as it obviously states, you may have imported these but have not used all of them.

Besides that being the obvious warning, your imports should have been

import numpy as np

NOT bumpy.

And remove the unnecessary period following the pandas import.

import pandas as pd

But if you still want to have imports and not use them, or keep them for later declarations, you could choose to suppress or ignore the warnings, which I do not endorse. But, if you so badly want to get rid of 'em, you can do so by adding the following line to the beginning of your code.

import warnings
warnings.filterwarnings("ignore")

推荐阅读