方法一 执行字符 string exec(string) 来自 https://www.google.com/search?q=python+run+string&sxsrf=ALiCzsbTxywiSaxfFbMNY843zs8FmuSESA%3A1666984886505&ei=titcY463HozXkwXisICoBw&ved=0ahUKEwiO6oXQ0oP7AhWM66QKHWIYAHUQ4dUDCA8&uact=5&oq=python+run+string&gs_lcp=Cgdnd3Mtd2l6EANKBAhBGABKBAhGGABQAFgAYABoAHAAeACAAQCIAQCSAQCYAQA&sclient=gws-wiz 方法二 f’string_statements {variable_name [: {width}.{precision}]}’ 来自 https://www.electroniclinic.com/python-string-format-string-format-specifiers-escape-sequences-raw-format/ 方法三 eval(‘sdkjahfsahfsdnsf’) 但是这种方法只能运行表达式