Discuss / Python / 整数转欢成小数

整数转欢成小数

Topic source

玹帝

#1 Created at ... [Delete] [Delete and Lock User]

<pre><code>def str2float(s): def char2num(n): digits = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9} return digits[n] return reduce(lambda x,y: x10+y,map(char2num,s.replace('.','')))/(10*(len(s)-s.find('.')-1)) </code></pre>

将整数算出,在根据小数点位置除以一定数值,得出小数

玹帝

#2 Created at ... [Delete] [Delete and Lock User]

<pre><code>hhhh**hhhh</code></pre> 咋没有用?

玹帝

#3 Created at ... [Delete] [Delete and Lock User]

jjjj

玹帝

#4 Created at ... [Delete] [Delete and Lock User]

<pre><code>hhhh**hhhh</code></pre> 代码块到底有效果吗

玹帝

#5 Created at ... [Delete] [Delete and Lock User]

<pre><code>hhhh**hhhh</code></pre>

玹帝

#6 Created at ... [Delete] [Delete and Lock User]

<pre><code>hddhh</code></pre>

玹帝

#7 Created at ... [Delete] [Delete and Lock User]

<pre>hhhh**hhhh ddddd</pre>

玹帝

#8 Created at ... [Delete] [Delete and Lock User]
hhhh**hhhh
电动车

得得得


  • 1

Reply