I use But when I run it, I get a syntax error. what's wrong with it? If I can not assign an assignment in Use Read: eval () to specify a list in var:
eval ('mylist = [1,2,3]')
eval () , how do I specify a var in sequence?
exec for the statement:
& gt; & Gt; & Gt; Exec 'lis = [1,2,3]' & gt; & Gt; & Gt; LIS [1, 2, 3]
eval works on expressions only, such as
2 * 2 ,
4 + 5 etc.
eval and
exec is fine if the string is coming from a known source, but do not use them if String is coming from an unknown source (user input).
No comments:
Post a Comment