Python学习3:字符串操作
来源:互联网 发布:测量编程视频教学 编辑:程序博客网 时间:2024/06/06 06:36
所有programer开发的语言Index都是0开始;
所有programer开发的语言都是左闭右开。
字符串操作
pystr = 'Python'print pystrprint pystr[:] #代表所有print pystr[0:3] #第0,1,2print pystr[1:3] #第1,2print pystr[1:] #第2及以后print pystr[:1] #第0print pystr[-1] #最后一个print '#' * 20 #打印20个isCool = 'is cool'print pystr + isCool + '!'print pystr * 2print '#' * 20pystr = 100print pystr * 2print '%d is cool' % pystr #这里的d s f x o 等和C语言一致print '%s is cool' % pystrprint '%f is cool' % pystrprint '%x is cool' % pystrprint '%o is cool' % pystrprint '%c is cool' % pystrprint str(pystr)+' is cool' #可以用str()转化为字符串print '#' * 20
结果如下:
PythonPythonPytytythonPn####################Pythonis cool!PythonPython####################200100 is cool100 is cool100.000000 is cool64 is cool144 is coold is cool100 is cool####################Process finished with exit code 0
阅读全文
0 0
- Python学习3:字符串操作
- Python学习---字符串操作
- python学习:字符串操作
- Python学习-字符串操作
- python学习-字符串操作
- python学习:字符串切片操作
- python学习006--字符串操作
- Python学习(字符串操作)
- python字符串操作学习小结
- python的学习(五)----字符串操作
- Python学习笔记:字符串基本操作
- Python学习笔记--字符串操作string
- Python学习13:字符串操作函数使用
- Python学习(三): 字符串操作
- python学习笔记(字符串常见操作)
- python学习笔记之二:字符串操作
- python学习五(字符串操作)
- python学习 原始字符串操作符 print
- 最近了解到的知识点
- 搭建并配置splunk
- jquery 操作 checkbox 全选、反选、清除
- 扫盲一: 加密, 认证, 公钥,私钥,证书
- 安装realsense ros包时找不到librealsenseconfig.cmake 问题解决
- Python学习3:字符串操作
- caffe之solver.prototxt文件参数设置
- @Autowired写在变量上和构造器上的区别
- 快速解决跨域请求资源
- lintcode--平面范围求和-不可变矩阵(leetcode--Range Sum Query 2D)
- Solidity(5)
- 特征选择与稀疏学习(Feature Selection and Sparse Learning)
- 代码感悟(1)
- iOS加密:AES+Base64