Home > other >  Consult a decimal retains the decimal digits
Consult a decimal retains the decimal digits

Time:10-13

When I was in processing the data need to keep three decimal places,
 test_data [I] [j]=(" %. 3 f "% test_data [I] [j]) 

Output results meet the third 0 automatically omit, such as 2.8396 will be 2.84, consult what method can put 0 to?

CodePudding user response:

The
refer to the original poster weixin_45779951 response:
when I was in processing the data need to keep three decimal places,
 test_data [I] [j]=(" %. 3 f "% test_data [I] [j]) 

Output results meet the third 0 automatically omit, such as 2.8396 will be 2.84, consult what method can put 0 to?

Couldn't find any way may be I don't know, the easiest way is to force truncation, truncate a 2.8396 2.839

CodePudding user response:

Using round function?

CodePudding user response:

A decimal function also can have a try,

CodePudding user response:

Well, when I run, output is STR format of '2.840'

CodePudding user response:

reference 4 floor max5173 response:
well, I run, output is STR format of '2.840'

What version? We are keep two decimal places

CodePudding user response:

The data of the original figures have BaJiuWei, out as long as it is involved in a zero were omitted

CodePudding user response:

reference python_student reply: 3/f
decimal function also can have a try,
round and this are tried, the result

CodePudding user response:

refer to 7th floor weixin_45779951 response:
Quote: reference python_student reply: 3/f
decimal function also can have a try,
round and this are tried, the result is as

CodePudding user response:

reference 5 floor JMZL reply:
Quote: refer to 4th floor max5173 response:
well, I run, output is STR format of '2.840'

What version? We are to keep two decimal places
IDLE for 3.7

CodePudding user response:

With the float (3)
  • Related