本文介绍了3号和点..的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 嗨.. 我想这样做: 考试: 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 假设点总是在字符串的第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 .... (0,12,332,321) ''12 .332.321'' - 保罗 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 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.21This is wrong it would be 12.332.321 .... (0, 12, 332, 321) ''12.332.321'' -- Paul 这篇关于3号和点..的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-19 18:42