2010-07-23 4 views

답변

14

내장 된 pow은 두 개 또는 세 개의 인수를 취합니다. from math import *을 입력하면 수학의 pow으로 바뀌고 두 개의 인수 만 사용됩니다. 내 추천은 import math이거나 가져 오기 목록에서 사용하는 함수를 명시 적으로 나열하는 것입니다. openos.open과 유사한 문제가 발생합니다.

+0

아 ... 어쩌면 그것이 이유입니다. 감사!!!!! 오류 ... 다른 파일에서 가져 오기가 영향을 줍니까? 내가 작성한 또 다른 프로그램을 임포트하는 것은'from math import * '입니다. – calccrypto

+0

@calccrypto :'from p import *'로 다른 프로그램을 import하는 중이라면'yes '를 선택하십시오. 'import p'를 사용하거나 p import [...]'에서 명시 적으로 나열하십시오. – sdcvvc

0

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 아닌가요?

+0

없음에 대한 __builtin__ .pow을 __builtin__을 가져 호출하는 것입니다. 모든 값이 양의 정수인지 확인하십시오 편집 : 예. a, b, c = 9, 4, 225 – calccrypto

1

당신은 파이썬 2.7에서이 문제를 해결 수학 함수에게 많이 펑의 세 가지 매개 변수 버전 자주하는 방법을 사용하는 경우는 3 paramete

+0

두 경우 모두 'builitin'의 양쪽에 두 개의 밑줄 문자가 있어야하지만 서식에서 굵은 글꼴로 해석되므로 서식에 대해 무엇을해야할지 확실하지 않습니다. –