Learning Python(5.3):Some question!

王朝other·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

5.3 String Formatting

Q1: I know what is %e, %f, but I really can not understand %g, especially when the book interprets it as “Floating-point e or f”. What is 'or'? How does computer determine it is e or f?

Q2: I don't know what is “left justification (-)”, of course it is not a numeric sign!

Q3: I can't understand the width in formatting and the zero padding! For example:

>>> x = 1.23456789

>>> '%-6.2f | %05.2f | %+06.1f' % (x, x, x)

'1.23 | 01.23 | +001.2'

Of course the precision means the width after the decimal point, but what the width before it?

Maybe I can ask them in the google group!

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航