元组和字符串
来源:互联网 发布:淘宝代付可以用微信吗 编辑:程序博客网 时间:2024/04/29 18:51
代码:
# -*-coding:utf-8 -*-#元组#访问元组tup1=('a','b',1997,2000)tup2=(1,2,3,4,5,6,7)print 'tup1[0]:',tup1[0]print 'tup2[1:5]:',tup2[1:5]# 元组连接tup3=tup1+tup2print tup3# 删除元组del tup1#字符串#查找s="python"print s.index('p')print s.index('h',1,4)print s.find('s')print s.find('h',1)#替换print s.replace('h','i')print s#计数print s.count('n')#以空格作为分隔符进行分割ss="hello i like eating"print ss.split()s1="you|are|so|beautiful"print s1.split('|')#join组合li=['apple','pear','banana']sep=','qq=sep.join(li)print qq
运行结果:
0 0
- 元组和字符串
- 字符串和元组
- 列表、元组和字符串
- python序列:字符串,元组和列表
- Python序列:字符串、列表和元组
- python 序列:字符串、列表和元组
- 6.序列:字符串、列表和元组
- Python:字符串、列表和元组
- python基础知识-元组和字符串
- [Language]Python序列--字符串和列表和元组
- python 字符串、元组
- python字符串、元组和列表常用的一些方法
- 序列(字符串,列表,元组)和字典常用方法
- python基础教程__列表、元组、字符串和字典
- Python基础:03序列:字符串、列表和元组
- 第六章:序列--字符串、列表和元组
- Python序列:字符串、列表和元组(一)
- Python序列:字符串、列表和元组(二)
- FPGA:下一代机器人感知处理器
- set 容器
- 大白话讲解SVM
- [设计模式]责任链模式(Chain of Responsibility)
- Java关键字final、static使用总结
- 元组和字符串
- multimap容器
- 第十二周
- linux下多线程的使用 pthread_create()
- 学习opencv跟轮廓相关的
- Android的单例模式的N种实现方式
- 103. Binary Tree Zigzag Level Order Traversal
- 将一个字符串数组排序
- https中请求http资源报错Mixed Content