Premium Necro 78 Posted December 23, 2014 Premium Share Posted December 23, 2014 How can i hide end of number 3,78889564646 that it was look like 3,78 in python code? Thank you Link to comment Share on other sites More sharing options...
Premium Sanchez 2465 Posted December 23, 2014 Premium Share Posted December 23, 2014 https://docs.python.org/2/library/decimal.html#decimal-faq Or just split it: test = "3.78889564646" float(test[:test.find('.')+3]) 1 Link to comment Share on other sites More sharing options...
Premium Necro 78 Posted December 23, 2014 Author Premium Share Posted December 23, 2014 I have it like this: test replace with PetProcentExp def _GameWindow__PetExp(self, PetProcentExp): self.PetExpLabel.SetText(float(PetProcentExp[:PetProcentExp.find('.')+3]) + "%") self.PetExpBar.SetPercentage(PetProcentExp, 100) syserr: unsupported operand types for +: 'float' and 'str' Link to comment Share on other sites More sharing options...
Premium Sanchez 2465 Posted December 23, 2014 Premium Share Posted December 23, 2014 You trying to append a string to an int which is not allowed. str(float(PetProcentExp[:PetProcentExp.find('.')+3])) + "%" Link to comment Share on other sites More sharing options...
sxvoyz 61 Posted December 23, 2014 Share Posted December 23, 2014 self.PetExpLabel.SetText("%.2f" % float(3.78889564646)) 1 Link to comment Share on other sites More sharing options...
sxvoyz 61 Posted December 23, 2014 Share Posted December 23, 2014 (edited) nah Edited December 23, 2014 by sxvoyz Link to comment Share on other sites More sharing options...
Premium Necro 78 Posted December 23, 2014 Author Premium Share Posted December 23, 2014 You trying to append a string to an int which is not allowed. str(float(PetProcentExp[:PetProcentExp.find('.')+3])) + "%" Thank but still was a problem. self.PetExpLabel.SetText("%.2f" % float(3.78889564646)) Thank you very much..now its work. Solved Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now