当前位置:网站首页>Section 5 of Chapter 2: search and judgment
Section 5 of Chapter 2: search and judgment
2022-07-21 15:15:00 【Zhongyifeng Digital Technology Co., Ltd】
Python Basic introduction ( A full set of nanny level tutorials )
Chapter two
Section 5 : Find and judge
**find:** Output returns if -1 The string does not appear .
index: If you report an error, there is no .
in You can make conditional judgments ,not in Determine whether there is no .
s = " How do you do . My name is Chow Yun fat "
ret = s.find(" Chow yun-fat 12312") # Return if yes -1 The string does not appear
print(ret)
ret = s.index(" Chow yun-fat 12312") # If you report an error, there is no
print(ret)
print(" Chow yun-fat " in s) # in You can make conditional judgments
print(" Chow yun-fat " not in s) # not in Determine whether there is no
**startswith:** Determine whether the string is based on xxxxx start , endswith() And startswith contrary , Try it yourself .
**isdigit:** Determine whether the string consists of integers .
name = input(" Please enter your name :")
# Judge whether your surname is Zhang
if name.startswith(" Zhang "): # Determine whether the string is based on xxxxx start , endswith()
print(" Your name is Zhang ")
else:
print(" No, Zhang ")
money = input(" Please enter your money :")
if money.isdigit(): # Determine whether the string consists of integers .
money = int(money)
print(" You can spend money ")
else:
print(" I'm sorry , Your input is wrong ....")
summary :
Remember these startswith(), isdigit(), in, not in, find.
边栏推荐
- 基于可见光通信的移动机器人室内定位及物联网应用
- 解决npm 安装 nrm遇到报错问题SyntaxError: Unexpected token import
- 版本号自增
- DevExpress XtraReport报表开发相关知识点
- Web3流量聚合平台Starfish OS,给玩家元宇宙新范式体验
- Math.random()的用法
- 3D转换之三维坐标系,透视旋转等基础知识
- 修改电脑注册表,将VSCode添加至鼠标右键菜单
- Web3流量聚合平台Starfish OS,诠释真正商业的“P2E”生态
- Opportunities and challenges coexist for financial enterprises to go to sea in emerging markets, advance AI ensures its safety and compliance development
猜你喜欢
DevExpress TreeList 实现父节点列值选中,其下子节点也全部选中
Nacos cluster construction
Yunna | dynamic environment monitoring system inspection, general introduction to the functions of the dynamic environment monitoring system
DAMA-总结(数据管理的总结)
leetcode:689. Maximum sum of three non overlapping subarrays
NFS共享存储服务
Expose the insider of Apache Doris data Lake analysis technology? Rare earth Developers Conference free registration!
Mysql的主键UUID、自增ID、雪花算法到底该怎么选择?(荣耀典藏版)
Automatic invoice processing - get rid of the shackles of paper and data input, automate workflow and exception handling, and significantly shorten the audit preparation time
asp.net -GridView自带的删除行项超链接用法(DeleteButton)
随机推荐
乘数科技云管控平台适配阿里云 PolarDB,共促云原生数据库生态繁荣
【C 练习】求一个数最少需要多少步可变为斐波那契数
HVV蓝队之入侵排查
This startup wants to see your Ding Ding! They use AI to detect sexual diseases and ensure data anonymity and encryption. Would you like to
How to ensure data security while saving 30% disk space in tdsql PG version DB · insight
How to solve the garbled Chinese annotation of idea import project
基于可见光通信的移动机器人室内定位及物联网应用
[binary tree] maximum product of split binary tree
[applet] come and develop your first wechat game (detailed process)
leetcode:689. 三个无重叠子数组的最大和
深拷贝函数
leetcode:407. Connected to rainwater II
图解LeetCode——1260. 二维网格迁移(难度:简单)
面试中常见的的 web 安全问题
Research Report - visible light communication and visible light positioning
Kingbasees database administrator's Guide -- 15.1 Manage views
[kaggle] how to effectively avoid oom (out of memory) and long alchemy process
Implementation details of SAP e-commerce cloud Spartacus UI sitecontexturlparams
nacos集群搭建
SQL: SELECT t.`app_ code`, SUM(t.`success_num`) AS success_ num, SUM(t.`