【python】字符串的用法阶进
来源:互联网 发布:买网站域名 编辑:程序博客网 时间:2024/05/21 03:18
字符串的格式¶
s1= r'abcd' #raw,原始数据
s2= u'abcd' #unicode 数据
他们的区别:
s1= r'\nabcd'
s2= u'\nabcd'
print s1
print s2
print len(s1)
print len(s2)
如何让字符串中含有引号 ",'
s3=""" """
S3= """ hello,say:'world'..."""
内置函数¶
find
s1 = "hello"
l = s1.find("l")
replace
>>> s1.replace('l','bc')
'hebcbco'
split
s1 ="name:john,age:23,job:jeapedu"
l1= s1.split(',')
l2=l1[0].split(":")
strip 去掉 首尾' ' ,'\n'
s = 'hello\n\n\n'
print len(s)
s = s.strip()
print len(s)
不能删除中间的' ' ,'\n'
In [33]: s = ' hello\n\n '
In [34]: s = s.strip()
In [35]: print len(s)
5
In [36]: s = ' hel lo\n\n '
In [37]: print len(s)
10
In [38]: s = s.strip()
In [39]: print len(s)
6
- 【python】字符串的用法阶进
- Python 原始字符串(raw strings)的用法
- Python笔记——字符串的用法
- Python中字符串的split用法
- python字符串前'r'的用法
- 【python】format函数格式化字符串的用法
- python中字符串的常用用法汇总
- python,格式化字符串函数.format()的用法
- Python字符串知识点总结(字符串的一些用法)
- python学习之 字符串前'r'的用法
- Python r 原始字符串(raw strings)的用法
- Python 在字符串前面加'r'的用法
- Python中用format函数格式化字符串的用法
- Python中用format函数格式化字符串的用法
- Python中用format函数格式化字符串的用法
- Python中用format函数格式化字符串的用法
- python学习之 字符串前'r'的用法
- Python中用format函数格式化字符串的用法
- Asp.Net MVC中的约定
- java【源码】员工管理系统
- 老孟 DB2 V9.7 ESE(一)产品部署 基于centOS 6.4
- 黑马程序员第-myeclipse快捷键大全
- 猜一个数
- 【python】字符串的用法阶进
- jQuery中.bind(),.live()和.delegate()的区别
- HttpURLConnection和HttpClient获取Json数据
- 微信安卓内置浏览器文本换行bug解决
- 【资料整理】CentOS5.6 升级 Python2.4.3 到 2.7.5
- linux下安装svn 解决svn: Unrecognized URL scheme
- C# 委托
- ArcGIS网络分析之Silverlight客户端服务区分析(三)
- Smack 结合 Openfire服务器,建立IM通信,发送聊天消息