python把str转换为int
2015-08-24 21:04
627 查看
def str2int(s): def fn(x,y): return x+y def char2num(s): return {'0':0,'1':1,'2':2,'3':3,'4':4,'5':5,'6':6,'7':7,'8':8,'9':9}[s] return reduce(fn,map(char2num,s)) print(str2int('2468'))
相关文章推荐
- 在python中如何设置当前工作目录
- Python学习笔记:random模块
- python第三方库推荐 - dateutil
- Python 实现递归算法
- python 模块学习--Numpy
- python实现简单爬虫功能
- python常用模块
- Python中文件对象的访问模式
- python_学习笔记0824
- Python自然语言处理学习笔记之信息提取步骤&分块(chunking)
- Python写Excel文件
- Python学习笔记:概要
- python嵌套dict的深度遍历合并
- 在VS中安装Python
- python ftplib模块
- python中的read()、readline()与readlines()
- python 使用ioctl() 获得网卡IP 和MAC地址
- python字符串format函数学习
- python-virtualenv安装方法
- 【Python】[IO编程]文件读写,StringIO和BytesIO,操作文件和目录,序列化