方法一:
a
=
12.12300
#结果要求为12.123
b
=
12.00
#结果为12
c
=
200.12000
#结果为200.12
d
=
200.0
#结果为200
print
'a==>'
,[
str
(a),
int
(a)][
int
(a)
=
=
a]
print
'b==>'
,[
str
(b),
int
(b)][
int
(b)
=
=
b]
print
'c==>'
,[
str
(c),
int
(c)][
int
(c)
=
=
c]
print
'd==>'
,[
str
(d),
int
(d)][
int
(d)
=
=
d]
方法二:
for
i
in
[
12.12300
,
12.00
,
200.12000
,
200.0
]:
print
(
'{:g}'
.
format
(i))