Get int-type from 'int' string

后端 未结 4 834
Happy的楠姐
Happy的楠姐 2021-01-25 08:21

In Python, given the string\'int\', how can I get the type int? Using getattr(current_module, \'int\') doesn\'t work.

4条回答
  •  伪装坚强ぢ
    2021-01-25 09:03

    Try with an eval():

    >>>eval('int')
    
    

    But be sure of what you give to eval(); it could be dangerous.

提交回复
热议问题