本文实例讲述了python每次处理一个字符的三种方法。分享给大家供大家参考。
具体方法如下:
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
打印出的结果如下:
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]
希望本文所述对大家的Python程序设计有所帮助。
最后
以上就是现实手链最近收集整理的关于python实现每次处理一个字符的三种方法的全部内容,更多相关python实现每次处理一个字符内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复