如何删除字符串的括号以便在函数中使用它?

How can I remove a string's parentheses so it can be used in functions?

如果我进行函数调用 check('list') 并且在我正在定义的函数中,它被称为检查,我想使用 if isinstance(value, x): 其中 x 是检查的参数,当前 'list' 但它可以是任何变量类型,有没有一种简单的方法可以使用 list 而不是 'list'

this相同。

typemap = {
  'list': list
   ...
}

def check(x):
   ...
  if isinstance(value, typemap[x]):
     ...

但实际上你应该直接传递 list