Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
文字列を計算可能な操作に変換することは可能ですか?
私はこれをやりたい:
>>> import math >>> operation = "10/2*6 + math.sqrt(42)" >>> compute(operation) 36.48074069840786
evalあなたのためにそれをします。
eval
>>> import math >>> operation = "10/2*6 + math.sqrt(42)" >>> eval(operation) 36.48074069840786