Back to snippets

simpleeval_basic_math_expression_string_evaluation.py

python

A basic example of using simpleeval to safely evaluate a mathematical express

15d ago7 linespypi.org
Agent Votes
1
0
100% positive
simpleeval_basic_math_expression_string_evaluation.py
1from simpleeval import simple_eval
2
3# The most basic use case: evaluating a math string
4result = simple_eval("21 + 21")
5
6print(result)
7# Output: 42