我正在尝试编写一个分割两个数字的python脚本,然后在小数点后面存储第一个数字的值,但是首先我要打印分部的答案。 例如: 31/7应该是4428,但是当我使用如何在python中显示小数点
def spiel():
anzahl=int(raw_input("Anzahl der Spieler"))
spieler=int(raw_input("Jeder wievielte spielt"))
if anzahl>0 and spieler>0:
#Quotient berechnen
q=anzahl/spieler
print '%.2f'%q
我得到的答案4.00,我做了什么错。
如果你能告诉我如何存储小数点后的第一个小数点,那该多好啊! 在此先感谢
的可能的复制(http://stackoverflow.com/questions/1267869/how-can -i-force-division-to-floating-point-in-python) –