• Курсы
  • Компилятор кода
  • Обсуждения
  • Цены
  • Teams
Menu
0

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

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

intpystroperands
21st Jan 2019, 1:42 PM
Shumpei Sori
Shumpei Sori - avatar
1 ответ
+ 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

Часто задают такие вопросы?

Учитесь эффективнее, бесплатно:

  • Введение в Python

    7.1M учащихся

  • Введение в Java

    4.7M учащихся

  • Введение в C

    1.5M учащихся

  • Введение в HTML

    7.5M учащихся

Смотреть все курсы
Актуальное сегодня
Fix Rivers in 2D Terrain Map Generator
5 Votes
What Is the most complicated thing you can do
1 Votes
How the operators and commands in this code are executed?
1 Votes
Hello everyone, I want to learn programming, I don't know where to start.
1 Votes
Combination
0 Votes
Will I get the certificate for free if I completed the free course of web development (I am not on pro subscription)
0 Votes
Somebody knows how to solve the problem finance app. Even my result is like it must be, but still I can't pass it
0 Votes
I finished introduction to python
0 Votes
i am begineer
0 Votes
UI and UX
1 Votes