문제

What is the simplest method to convert variable like

x=7.36/1

into rational fraction like

x=736/100
도움이 되었습니까?

해결책

from fractions import Fraction

Fraction(7.36/1).limit_denominator()
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top