+ 4
What is the use of eval function in Python??
3 Antworten
+ 10
It's used to evaluate Python expressions but using this to evaluate user input is dangerous because eval('__import__("os").system("rm -rf /")') wil start deleting every file on your computer
https://nedbatchelder.com/blog/201206/eval_really_is_dangerous.html
+ 3
Ok thanks for ur concern,
Pulkit Kamboj, Mert Yazlcl.
0
Eval converts a string to normal text
print('1*2*3')
will print 1*2*3
But, print(eval('1*2*3'))
Will be same as print(1*2*3)
So, output will be 6.