欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

python實(shí)現(xiàn)每次處理一個(gè)字符的三種方法

 更新時(shí)間:2014年10月09日 15:29:37   投稿:shichen2014  
這篇文章主要介紹了python實(shí)現(xiàn)每次處理一個(gè)字符的三種方法,是非常實(shí)用的字符串操作技巧,需要的朋友可以參考下

本文實(shí)例講述了python每次處理一個(gè)字符的三種方法。分享給大家供大家參考。

具體方法如下:

a_string = "abccdea" 
 
print 'the first' 
for c in a_string: 
  print ord(c)+1 
 
   
print "the second"   
result = [ord(c)+1 for c in a_string] 
print result 
 
print "the thrid" 
 
def do_something(c): 
  return ord(c)+1 
 
result = map(do_something ,a_string) 
print result 

打印出的結(jié)果如下:

the first 
98 
99 
100 
100 
101 
102 
98 
the second 
[98, 99, 100, 100, 101, 102, 98] 
the thrid 
[98, 99, 100, 100, 101, 102, 98] 

希望本文所述對(duì)大家的Python程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論