Python - 用python实现split函数
2024-10-08 13:21:44
# pattern支持字符或者字符串
def my_split(string, pattern):
ret = []
len_pattern = len(pattern)
while True:
index = string.find(pattern)
if index == -1:
ret.append(string)
return ret
else:
ret.append(string[:index])
string = string[index+len_pattern:]
if __name__=="__main__":
print(my_split("abcded", "cd"))
print(my_split("abcded", "d"))
最新文章
- mysql 用法记录和常见错误,持续更新。
- macbook 重装win7
- Block作为property属性实现页面之间传值(代替Delegate代理与协议结合的方法)
- 堡垒机 paramiko代码
- 如何鉴别程序抄袭c语言程序代写
- ELK Packetbeat 部署指南(15th)
- DTD简单使用
- MVC-04 视图(2)
- (76) Clojure: Why would someone learn Clojure? - Quora
- 获取IIS版本
- Unity UGUI实现分段式血条
- Drupal7.8的安装注意的问题
- Linux系统的数据写入机制--延迟写入
- Spine用于Timeline(NullReferenceException: Object reference not set to an instance of an object pine.Unity.Editor.AnimationReferenceAssetEditor.OnInspectorGUI ())
- Zabbix监控中,使用的比较好的动作信息模板
- asp.net core 发布到 docker 容器时文件体积过大及服务端口的配置疑问
- Tomcat 9.0 安装配置
- poj2632 【模拟】
- python中的%s%是什么意思
- POJ 3662 Telephone Lines (二分+Dijkstra: 最小化第k大的值)
热门文章
- SpringBoot--自动配置原理-4个注解
- [Web安全]SQL注入
- @Html.DropDownList()的四种用法及自定义DropDownList扩展
- 1.spring异常:Caused by: java.lang.NoClassDefFoundError: org/aopalliance/intercept/MethodInterceptor
- (转)KMP算法
- python itertool 浅谈迭代工具
- java基础之 修饰符
- jvm(1):内存结构
- 在Linux服务器上安装Python3.7
- Educational Codeforces Round 76 (Rated for Div. 2) C. Dominated Subarray