python string.atof( )函数
来源:互联网 发布:数据库应用系统的构成 编辑:程序博客网 时间:2024/06/18 13:40
string.atof(s)将字符串转为浮点型数字
>>> string.atof("1.23") 1.23 >>> string.atof("1") 1.0
string.atoi(s,[base=num])将字符串转为整型数字,base 指定进制
>>> string.atoi("20") 20 >>> string.atoi("20",base=10) 20 >>> string.atoi("20",base=16) 32 >>> string.atoi("20",base=8) 16 >>> string.atoi("20",base=2) Traceback (most recent call last): File "", line 1, in <module> File "/usr/lib64/python2.6/string.py", line 403, in atoi return _int(s, base) ValueError: invalid literal for int() with base 2: '20' >>> string.atoi("101",base=2) 5 >>> string.atoi("101",base=6) 37
string.capwords(s,sep=None)以sep作为分隔符,分割字符串s,然后将每个字段的首字母换成大写
>>> string.capwords("this is a dog") 'This Is A Dog' >>> string.capwords("this is a dog",sep=" ") 'This Is A Dog' >>> string.capwords("this is a dog",sep="s") 'This is a dog' >>> string.capwords("this is a dog",sep="o") 'This is a doG' >>>
string.maketrans(s,r)创建一个s到r的转换表,然后可以使用translate()方法来使用
>>> replist=string.maketrans("123","abc") >>> replist1=string.maketrans("456","xyz") >>> s="123456789" >>> s.translate(replist) 'abc456789' >>> s.translate(replist1) '123xyz789'
0 0
- python string.atof( )函数
- atof函数
- atof 函数参考
- atof()函数实现
- atoi()和atof()函数
- atof()函数学习
- atof & aoti 函数实现
- atof函数的实现
- atof 函数说明
- java 实现atof函数
- C++ atof函数
- atof函数的编写
- atoi()和atof()函数
- atof函数详解
- atof函数的实现
- atof函数 C++用法
- 一天一个CRT函数 atof
- C函数源码解读:atof
- 《安卓笔记》——Parcelable接口
- 164. Maximum Gap【H】【80】【桶排序】【VIP】
- 位运算
- Can not find the tag library descriptor for "http://Java.sun.com/jsp/jstl/core"
- 2012年第三届蓝桥杯C/C++程序设计本科B组决赛 数据压缩(代码填空)
- python string.atof( )函数
- K最近邻(KNN,k-Nearest Neighbor)准确理解
- jboss启动超时问题
- 【设计模式】:23种设计模式
- [Objective-C]关联(objc_setAssociatedObject、objc_getAssociatedObject、objc_removeAssociatedObjects)
- Android viewHolder缓存RecyclerView,ListView
- 2012年第三届蓝桥杯C/C++程序设计本科B组决赛 拼音字母(编程大题)
- Python装饰器学习(九步入门)
- 数据库查询条件语法