As the title says, if var a="print (1)", how can I make this a code run

You could try the Expression class, but it only supports some expressions.
https://docs.godotengine.org/en/stable/classes/class_expression.html

Or maybe the Script class.
https://docs.godotengine.org/en/stable/classes/class_script.html

Godot 4 has lambda functions, which are somewhat similar to what you want.
https://docs.godotengine.org/en/latest/tutorials/scripting/gdscript/gdscript_basics.html#lambda-functions