+ 1
executing string
How can I execute a string? When it is in variable! -- Like opening a file having a Source code --
5 odpowiedzi
+ 1
Pls tell me how
+ 1
Pls tell me
+ 1
Let's say you have a file containing this source-code called myCode.py
age = 27
msg = "I am "+ (str(age)) + " years old"
print(msg);
if you want to execute that code, you'll have to open the file, read it's contents and execute them.
exec(open("myCode.py").read)
0
What do you mean by executing s string
0
Thanks