• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell
您的位置:首页 > 脚本语言 >python > python实现每次处理一个字符的三种方法

python实现每次处理一个字符的三种方法

作者:shichen2014 字体:[增加 减小] 来源:互联网

shichen2014 通过本文主要向大家介绍了python转义字符,python 格式化字符,python 字符转数字,python 字符,python 替换字符等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com

本文实例讲述了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 

</div>

打印出的结果如下:

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] 

</div>

希望本文所述对大家的Python程序设计有所帮助。

</div>

您可能想查找下面的文章:

  • Python 转义字符详细介绍
  • python处理html转义字符的方法详解
  • Python随机生成带特殊字符的密码
  • Python实现查找系统盘中需要找的字符
  • Python实现查找系统盘中需要找的字符
  • Python文件读取的3种方法及路径转义
  • Python中每次处理一个字符的5种方法
  • Python实现对比不同字体中的同一字符的显示效果
  • Python 正则表达式(转义问题)
  • python实现每次处理一个字符的三种方法

相关文章

  • Python计算字符宽度的方法
  • Pycharm学习教程(7)虚拟机VM的配置教程
  • asyncio 的 coroutine对象 与 Future对象使用指南
  • Python中列表、字典、元组、集合数据结构整理
  • Python定时执行之Timer用法示例
  • 使用 Python 获取 Linux 系统信息的代码
  • 讲解Python中if语句的嵌套用法
  • Ubuntu 16.04 LTS中源码安装Python 3.6.0的方法教程
  • Python脚本实现自动发带图的微博
  • pygame学习笔记(4):声音控制

文章分类

  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell

最近更新的内容

    • python将MongoDB里的ObjectId转换为时间戳的方法
    • Python import自定义模块方法
    • Python脚本实现代码行数统计代码分享
    • Python的垃圾回收机制深入分析
    • Python去除列表中重复元素的方法
    • Python中使用Flask、MongoDB搭建简易图片服务器
    • python中cPickle用法例子分享
    • python通过zlib实现压缩与解压字符串的方法
    • Python文件读取的3种方法及路径转义
    • Python批量修改文件后缀的方法

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有