sh_17_字符串的查找和替换

hello_str = "hello world"

# 1. 判断是否以指定字符串开始
print(hello_str.startswith("Hello")) # 2. 判断是否以指定字符串结束
print(hello_str.endswith("world")) # 3. 查找指定字符串
# index同样可以查找指定的字符串在大字符串中的索引
print(hello_str.find("llo"))
# index如果指定的字符串不存在,会报错
# find如果指定的字符串不存在,会返回-1
print(hello_str.find("abc")) # 4. 替换字符串
# replace方法执行完成之后,会返回一个新的字符串
# 注意:不会修改原有字符串的内容
print(hello_str.replace("world", "python")) print(hello_str)

最新文章

  1. iOS静态库开发中对Bitcode的支持
  2. PHP 判断点是否在多边形内
  3. asp.net c#过滤html代码,净化DIV SPAN等
  4. android 屏幕旋转
  5. 使用C#和.NET的原因
  6. Fast and Robust Hand Tracking Using Detection-Guided Optimization
  7. Java基础之在窗口中绘图——显示曲线的控制点(CurveApplet 2 displaying control points)
  8. K650D安装黑苹果
  9. Reference in the manifest does not match the identity of the downloaded assembly
  10. ios越狱开发第一次尝试记录
  11. 迷途指针 new delete
  12. QT内置的ICON资源
  13. acdream 1211 Reactor Cooling 【边界网络流量 + 输出流量】
  14. web从入门开始(5)-----表单
  15. 关于SPI通信原理与程序实现
  16. jQuery -- 光阴似箭(四):jQuery 遍历
  17. 【DWM1000】 code 解密3一ANCHOR RUN起来
  18. 力扣(LeetCode)832. 翻转图像
  19. “2017面向对象程序设计(Java)第十三周学习总结”存在问题的反馈及本周教学安排
  20. NodeJS+Express开发web,为什么中文显示为乱码

热门文章

  1. Java object-oriented8/5
  2. oracle sqlplus执行sql语句字符集问题
  3. 动画方案 Lottie 学习(二)之实战
  4. RGB2GRAY 各种算法速度比较,整形乘法比查表法快!
  5. 【转载】linux SUID SGID
  6. 修改Vue中的 v-html 内的元素无效问题
  7. SQL*Loader 的使用sqlldr和sqluldr2方法详解
  8. (转)JVM垃圾回收机制
  9. 4G LTE 网只能提供数据服务,不能承载语音通话,该怎么理解?
  10. ath6kl 架构