Python切片(入门7)
2024-09-20 17:15:52
转载请标明出处:
http://www.cnblogs.com/why168888/p/6407977.html本文出自:【Edwin博客园】
Python切片
1. 对list进行切片
L = range(1, 101)
print L[:10]
print L[2::3]
print L[4:50:5]
2. 倒序切片
L = range(1, 101)
print L[-10:]
print L[-46::5]
3. 对字符串切片
def firstCharUpper(s):
return s[0].upper() + s[1:]
print firstCharUpper('hello')
print firstCharUpper('sunday')
print firstCharUpper('september')
最新文章
- asp.net权限控制配置web.config
- linux主机间复制文件
- :nth-child()和:nth-of-type(n)区别
- 企业级的App发布流程
- HTML5文档结构语义:页眉的header和hgroup标签使用
- NPOI的源代码编译
- Java架构必会几大技术点(转)
- Peter Pan By: J. M. Barrie
- AngularJs学习笔记5——自定义服务
- 内核加载与linux的grub
- checking for known struct flock definition... configure: error: Don't know how to define struct flock on this system, set --enable-opcache=
- C#、Java之比较
- bzoj3963[WF2011]MachineWorks cdq分治+斜率优化dp
- python-django(框架结构)
- PyCharm 使用Github管理Django项目
- mysql游标中使用临时表
- Qt532.QString_填充字符
- 限定某个目录禁止解析php 、限制user_agent 、php的配制文件、PHP的动态扩展模块
- Golang Email
- 高性能网络编程(一):单台服务器并发TCP连接数到底可以有多少