왜 Python은 IDLE에서 작동하지만 ("IDLE도 그렇다") 파이썬이 "TypeError : pow expected 2 arguments, 3"이라고 말하는 이유는 무엇입니까? 단순히 pow(a,b,c)
을하고 있습니다. 내 프로그램은 매우 짧고 나는 어떤 지수에 대해 사용해야하기 때문에 언제든지 pow
의 정의를 변경하지 않습니다.파이썬이 pow에 2 개의 인수 만있는 것을 말하는 이유는 무엇입니까
참고 :이
왜 Python은 IDLE에서 작동하지만 ("IDLE도 그렇다") 파이썬이 "TypeError : pow expected 2 arguments, 3"이라고 말하는 이유는 무엇입니까? 단순히 pow(a,b,c)
을하고 있습니다. 내 프로그램은 매우 짧고 나는 어떤 지수에 대해 사용해야하기 때문에 언제든지 pow
의 정의를 변경하지 않습니다.파이썬이 pow에 2 개의 인수 만있는 것을 말하는 이유는 무엇입니까
참고 :이
내장 된 pow
은 두 개 또는 세 개의 인수를 취합니다. from math import *
을 입력하면 수학의 pow
으로 바뀌고 두 개의 인수 만 사용됩니다. 내 추천은 import math
이거나 가져 오기 목록에서 사용하는 함수를 명시 적으로 나열하는 것입니다. open
대 os.open
과 유사한 문제가 발생합니다.
http://docs.python.org/release/2.6.5/library/functions.html
pow(x, y[, z])
Return x to the power y; if z is present, return x to the power y, modulo z (computed more efficiently than pow(x, y) % z). The two-argument form pow(x, y) is equivalent to using the power operator: x**y.The arguments must have numeric types. With mixed operand types, the coercion rules for binary arithmetic operators apply. For int and long int operands, the result has the same type as the operands (after coercion) unless the second argument is negative; in that case, all arguments are converted to float and a float result is delivered. For example, 102 returns 100, but 10-2 returns 0.01. (This last feature was added in Python 2.2. In Python 2.1 and before, if both arguments were of integer types and the second argument was negative, an exception was raised.) If the second argument is negative, the third argument must be omitted. If z is present, x and y must be of integer types, and y must be non-negative. (This restriction was added in Python 2.2. In Python 2.1 and before, floating 3-argument pow() returned platform-dependent results depending on floating-point rounding accidents.)
Math
이 아마도 당신이 굵은 부분을 위반하고, __builtin__
에서 pow
아닌가요?
없음에 대한 __builtin__
.pow을 __builtin__
을 가져 호출하는 것입니다. 모든 값이 양의 정수인지 확인하십시오 편집 : 예. a, b, c = 9, 4, 225 –
calccrypto
당신은 파이썬 2.7에서이 문제를 해결 수학 함수에게 많이 펑의 세 가지 매개 변수 버전 자주하는 방법을 사용하는 경우는 3 paramete
두 경우 모두 'builitin'의 양쪽에 두 개의 밑줄 문자가 있어야하지만 서식에서 굵은 글꼴로 해석되므로 서식에 대해 무엇을해야할지 확실하지 않습니다. –
아 ... 어쩌면 그것이 이유입니다. 감사!!!!! 오류 ... 다른 파일에서 가져 오기가 영향을 줍니까? 내가 작성한 또 다른 프로그램을 임포트하는 것은'from math import * '입니다. – calccrypto
@calccrypto :'from p import *'로 다른 프로그램을 import하는 중이라면'yes '를 선택하십시오. 'import p'를 사용하거나 p import [...]'에서 명시 적으로 나열하십시오. – sdcvvc