current position:Home>Pyqt5 how to output percentages directly?

Pyqt5 how to output percentages directly?

2022-02-04 16:50:53 CSDN Q & A

img


The interface is like this , The final score column wants to output the percentage .
If it is to use print, I know how to do it . What we use here is textedit, I don't know if there are more convenient controls ?




Take the answer :

You will be textedit The value inside is assigned first , In giving textedit Do reality , such as

 Original value =0.890909090909 Percentage ratio =f'{round( Original value *100,3)}%'textedit(showvalue= Percentage ratio )

Ideas First format the string or display value and then give it to textedit Show or give textedit Content assignment of



Other answers 2:
print('{:.2%}'.format(x))

Other answers 3:

you are here python The script sets a variable , In the input pyqt No. It'll be ok
Such as :text = '{}%'.format(0.890*100)
And then call :textedit(text)


Other answers 4:

use print And give text There's no difference in passing values
Do you use print If you don't format it, it's the same. A pile of decimal points

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.cdmana.com/2022/02/202202041650507618.html

Random recommended