惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

GbyAI
GbyAI
Blog — PlanetScale
Blog — PlanetScale
The GitHub Blog
The GitHub Blog
Microsoft Security Blog
Microsoft Security Blog
I
InfoQ
A
About on SuperTechFans
T
The Blog of Author Tim Ferriss
D
DataBreaches.Net
L
LangChain Blog
F
Fortinet All Blogs
C
Check Point Blog
Google DeepMind News
Google DeepMind News
云风的 BLOG
云风的 BLOG
Engineering at Meta
Engineering at Meta
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
H
Help Net Security
J
Java Code Geeks
月光博客
月光博客
H
Hackread – Cybersecurity News, Data Breaches, AI and More
IT之家
IT之家
aimingoo的专栏
aimingoo的专栏
小众软件
小众软件
宝玉的分享
宝玉的分享
Jina AI
Jina AI

博客园 - GeneJiang

窗口函数的使用 拉链表(Zipper Table)完整总结 —— 数据仓库 SCD Type 2 的经典实现 Kimball 维度建模:数据仓库领域最实用的“用户友好”方法论 DMP 数据接入测试全攻略:从“水龙头”把关到端到端信任 —— 理论解析 + 阿里云 DataWorks、AWS Glue、Azure Data Factory + 自研 EMR(基于 CDH)实战经验 ETL 全链路数据污染与逻辑错误定位实战经验分享 资产损失防控关键点-那些年被薅的“羊毛” 计算广告中常用的计算单位 MVC设计模式(Python) Jupyter NoteBook 的快捷键使用指南 Hive常用函数 Hive Tutorial(一) - Hive的数据类型 基于TestNG和Maven的接口测试之(一)- 基础配置 195 Tenth line-取第十行 Python常用库之Requests自我总结 Linux基本命令(一) Presto Step by Step之一Presto简介 Python常用的排序 CentOS7安装(三)- 配置阿里云yum源 OSQA的配置 MySQL学习 (三) Limit-Distinct-Union
python 判断字符串是否包含子字符串
GeneJiang · 2018-05-31 · via 博客园 - GeneJiang

第一种方法:in,主要是利用对象判断

string = 'helloworld'

if 'world' in string:
  print 'Exist'
else:
  print 'Not exist'

第二种方法:find

string = 'helloworld'
if string.find(’world‘) == 5: #5的意思是world字符从那个序开始,因为w位于第六个,及序为5,所以判断5
  print 'Exist'
else:
  print 'Not exist'

第三种方法:index,此方法与find作用类似,也是找到字符起始的序号

if string.index(’world‘) > -1: #因为-1的意思代表没有找到字符,所以判断>-1就代表能找到
  print 'Exist'

如果没找到,程序会抛出异常