我想在下面的例子中用'更好的函數替換'eval'。經過研究,我的理解是,使用這不是一個好主意。用於更好的替代eval功能
class_name = '{}'.format(SIP.supported_classes_dictionary[msg_type])
print 'Testing {}'.format(eval(class_name).supported_sip_services[msg_type])
variable_array = eval(class_name).fields_desc[2:]
小問題:'os'和'sys'不是類,它們是模塊。當然,它也適用於課程。 – jacg
奧普斯的確如此。有其他的想法。我改變了答案。 – allo