能,使用fractions(分数)模块,可以进行分数运算。使用fractions模块中的Fraction()函数可以自动约分分数。
from fractions import Fraction
print(Fraction(145,60))
执行结果:
29/12