3号和点.. [英] 3 number and dot..

查看:63
本文介绍了3号和点..的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨..

我想这样做:

考试:

12332321 == 12.332.321


我该怎么办?

解决方案

Abandoned写道:


嗨..

我想这样做:

for examle:

12332321 == 12.332.321


我该怎么办?



假设点总是在字符串的第3和第7位:


def conv(s,sep ="。"):

l = [s [0:3],s [3:6],s [6:]]

返回sep.join (l)


print conv(" 12332321")

-

pkm~ http://paulmcnett.com


10月31日,10:18下午,Paul McNett< p ... @ ulmcnett.comwrote:


Abandoned写道:


嗨..

我想这样做:

for examle:

12332321 == 12.332.321


我该怎么办?



假设点总是在字符串的第3和第7位:


def conv(s,sep ="。"):

l = [s [0:3],s [3:6],s [6:]]

返回sep.join (l)


print conv(12332321)


-

pkm~ http://paulmcnett.com



但它开始了从最后..

print conv(12332321)

123.323.21

这是错误的12.332.321


10月31日下午2:58,放弃< best ... @ gmail.comwrote:


嗨..

我想这样做:

的考试:

12332321 == 12.332.321

我该怎么办?


>> x =(12332321,)
while(x [0]> 0):x = divmod(x [0],1000)+ x [1:]



....


>> x



(0,12,332,321)


>>"。" .join(map(str,x [1:]))



''12 .332.321''


- 保罗


Hi..
I want to do this:
for examle:
12332321 ==12.332.321

How can i do?

解决方案

Abandoned wrote:

Hi..
I want to do this:
for examle:
12332321 ==12.332.321

How can i do?


Assuming that the dots are always in the 3rd and 7th position in the string:

def conv(s, sep="."):
l = [s[0:3], s[3:6], s[6:]]
return sep.join(l)

print conv("12332321")
--
pkm ~ http://paulmcnett.com


On Oct 31, 10:18 pm, Paul McNett <p...@ulmcnett.comwrote:

Abandoned wrote:

Hi..
I want to do this:
for examle:
12332321 ==12.332.321

How can i do?


Assuming that the dots are always in the 3rd and 7th position in the string:

def conv(s, sep="."):
l = [s[0:3], s[3:6], s[6:]]
return sep.join(l)

print conv("12332321")

--
pkm ~http://paulmcnett.com

But it''s starts from the end..
print conv("12332321")
123.323.21
This is wrong it would be 12.332.321


On Oct 31, 2:58 pm, Abandoned <best...@gmail.comwrote:

Hi..
I want to do this:
for examle:
12332321 ==12.332.321

How can i do?

>>x = (12332321,)
while (x[0]>0): x=divmod(x[0],1000)+x[1:]

....

>>x

(0, 12, 332, 321)

>>".".join(map(str,x[1:]))

''12.332.321''

-- Paul


这篇关于3号和点..的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆