手机
当前位置:查字典教程网 >脚本专栏 >python >python实现每次处理一个字符的三种方法
python实现每次处理一个字符的三种方法
摘要:本文实例讲述了python每次处理一个字符的三种方法。分享给大家供大家参考。具体方法如下:a_string="abccdea"print't...

本文实例讲述了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实现的Kmeans++算法实例

python 输出一个两行字符的变量

python 实现归并排序算法

Python实现多线程下载文件的代码实例

Python中针对函数处理的特殊方法

python实现问号表达式(?)的方法

采用python实现简单QQ单用户机器人的方法

python 测试实现方法

python调用shell的方法

python 获取本机ip地址的两个方法

精品推荐
分类导航