Execute a list

G

Groleo Marius

Hi.
How can i execute a string in python?
For example if I have the variable s, defined below
s = '"print "hello"'
How can I execute the code that "s" keeps inside, considering that the
code is correct?
 
M

Martin Miller

Here is how to execute code in a string, similar to what was shown in
your example:
hello

Hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,221
Messages
2,571,133
Members
47,747
Latest member
swapote

Latest Threads

Top