decimal
모듈을 직접 호출하는 대신 decimal.Decimal
을 사용하십시오. decimal
은 Decimal
, 'DefaultContext'
등의 속성을 포함하는 모듈 객체입니다. 이러한 속성에 액세스하려면 도트 표기법 (decimal.attr_name
)을 사용하십시오.
>>> import decimal
>>> decimal.Decimal('1.234')
Decimal('1.234')
>>> decimal.DefaultContext
Context(prec=28, rounding=ROUND_HALF_EVEN, Emin=-999999999, Emax=999999999, capitals=1, flags=[], traps=[Overflow, InvalidOperation, DivisionByZero])
또한 from decimal import ..
구문을 사용하여 현재 네임 스페이스로 선택된 속성을 가져올 수 있습니다 : 당신은 또한 bigfloat 패키지
The bigfloat package is a Python wrapper for the GNU MPFR library for arbitrary-precision floating-point reliable arithmetic.
당신은 당신이 원하는 정확하게 작업 할 수 있습니다
>>> from decimal import Decimal, DecimalTuple #import two attrs in current namespace
>>> Decimal('1.234') #now use it directly, no dot notation required
Decimal('1.234')
"10 진수 모듈을 사용해 보았지만, 작동하지 않는 가져 오기 또는 다른 것으로 인해 더 이상 사용할 수 없습니다."- 뭐라고 말합니까? – matino
"분명히 더 이상 사용할 수 없습니다"- 정교하게 말하십시오. 'decimal' *은 기본 파이썬 모듈이며 플랫폼 독립적입니다. –
파이썬 스크립트의 이름을 decimal.py로 지정 했습니까? "기능 외 수입"이란 무엇을 의미합니까? – Blender