Python 字符串
来源:互联网 发布:手机屏幕玻璃材质知乎 编辑:程序博客网 时间:2024/06/07 23:15
Python字符串:
在Python中的字符串被确定为一组连续的字符在引号之间。 Python允许在任何对单引号或双引号。串的子集,可以使用切片操作符可采用([]和[:]),索引从0开始的字符串的开始和结束(-1)。
加号(+)符号的字符串连接操作符,而星号(*)表示重复操作。例如:
#!/usr/bin/pythonstr = 'Hello World!'print str # Prints complete stringprint str[0] # Prints first character of the stringprint str[2:5] # Prints characters starting from 3rd to 5thprint str[2:] # Prints string starting from 3rd characterprint str * 2 # Prints string two timesprint str + "TEST" # Prints concatenated string
这将产生以下结果:
Hello World!
H
llo
llo World!
Hello World!Hello World!
Hello World!TEST“
0 0
- Python字符串
- Python 字符串
- python字符串
- python 字符串
- 【python】-字符串
- python 字符串
- python字符串
- python 字符串
- python,字符串
- python 字符串
- Python字符串
- Python字符串
- python字符串
- Python 字符串
- python 字符串
- Python 字符串
- Python字符串
- python 字符串
- easyui整理资料
- CAN总线IO模块~ISO9001认证
- Untiy保存截图保存到本地文件夹、并下载截图到场景里
- ORACLE转义字符的那点事
- Halcon模板匹配一
- Python 字符串
- 提示框的使用->UIAlertController类的使用
- 从GitHub下载最新的Android support拓展包源码
- 【杭电2015年12月校赛A】【水题 暴力】The Country List 多少个名字与其它名字more than 2位置字符相同
- 5年一个阶段的整理和总结
- java学习资料
- 占坑抽空补题解>_< 【杭电2015年12月校赛B】【计算几何】 Polygon 求直线和多边形的交线长度
- iOS检测网络连接状态
- MySQL字符集乱码简单讲解