aa ={}
if isinstance(aa,dict):
print("是")
aa =2
if isinstance(aa,dict):
print("是")
aa =2
if isinstance(aa,int):
print("是")
aa = []
if isinstance(aa,list):
print("list")
aa =[1,2,3]
if isinstance(aa,list):
print("list")
import numpy as np
aa = np.array([11,22,33])
if isinstance(aa,np.ndarray):
print("np.array")
import pandas as pd
import pandas as pd
# Create a pandas DataFrame
df = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]})
# Check if the variable 'df' is a pandas DataFrame
if isinstance(df, pd.DataFrame):
print("df is a pandas DataFrame")
else:
print("df is not a pandas DataFrame")
import scanpy as sc
import anndata
import numpy as np
# Create an AnnData object
adata = sc.AnnData(X=np.random.rand(3, 3))
# Check if the variable 'adata' is an AnnData object
if isinstance(adata, sc.AnnData):
print("adata is an AnnData object")
else:
print("adata is not an AnnData object")
if isinstance(df, sc.AnnData):
print("df is an AnnData object")
else:
print("df is not an AnnData object")
结果如下