0

How can I change str(+) to int(+) with python?

I'd like to change this x = ' 1 + 1 ' print(int(x)) output 2

21st Jan 2019, 1:42 PM
Shumpei Sori
Shumpei Sori - avatar
1 Réponse
+ 5
The simple answer would be eval(), but of course, ignoring how notorious it is: https://nedbatchelder.com/blog/201206/eval_really_is_dangerous.html
21st Jan 2019, 1:49 PM
Hatsy Rei
Hatsy Rei - avatar