“literal_eval in Python” Code-Antworten

Evalfunktion in Python

#eval()
z=eval(input("enter the list:"))
n=int(input("enter the list to search:"))
freq=z.count(n)
if freq>0:
    print(n,"occurs",freq,"times")
else:
    print(n,"does not occur")
Gr@Y_orphan_ViLL@in##

literal_eval in Python

# See https://docs.python.org/3/library/ast.html#ast.literal_eval for more information.

 print(ast.literal_eval('5*5'))  # This will throw ValueError(f'malformed node or string: {node!r}') which is different from eval's behavior
CompSciGeek

Bewertung in Python

#string in another string
expr="'2+3'"
print(eval(expr))
print(eval(eval(expr)))
Mighty Unicorn

Ähnliche Antworten wie “literal_eval in Python”

Fragen ähnlich wie “literal_eval in Python”

Weitere verwandte Antworten zu “literal_eval in Python” auf Python

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen