how to execute a string in python Sep
01
1
1

To run a string use `exec`

code = 'print "Hello World"'
exec code

If you need to pull a value from an expression use `eval`

foo = eval('1+1')
Bookmark and Share
blog comments powered by Disqus