A
A
Alaxay2020-07-28 13:52:44
Python
Alaxay, 2020-07-28 13:52:44

What does ".15g" do with format(float...?

This is a calculator. Line 3 allows you to display only the entered numbers, without zeros and commas.

what does ".15g" do anyway? Are there analogues?

def displayNumber(self,value):

        text = self.sender()

        newLabel = format(float(self.ui.label.text() + text.text()),".15g")
        self.ui.label.setText(newLabel)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Tikhonov, 2020-08-07
@alaxay

Here is the definition

V
Vadim Shatalov, 2020-07-28
@netpastor

https://pyformat.info/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question