何らかの理由で、私のスクリプトは Text Wrangler から直接実行することを拒否していますが、ターミナルにインポートすると正常に動作します。
import math
def main():
print("This program find the real solutions to a quadratic\n")
a,b,c, = eval(input("Please enter the coefficients (a,b,c): "))
discRoot = math.sqrt(b * b -4 * a * c)
root1 = (-b + discRoot) / (2 * a)
root2 = (-b - discRoot) / (2 * a)
print("\nThe solutions are:" , root1, root2)
main()
これを textwrangler で実行すると、「TypeError: eval() arg 1 must be a string or code object」というエラー メッセージが表示されます。次の入力が文字列ではなく整数であることを意味するために eval() を使用するポイントではありませんか? なぜこうなった?