当前位置:网站首页>Section 3 of Chapter 2: general operation of string
Section 3 of Chapter 2: general operation of string
2022-07-21 15:15:00 【Zhongyifeng Digital Technology Co., Ltd】
Python Basic introduction ( A full set of nanny level tutorials )
Chapter two
In the third quarter : String general operation
*** Generally, the operation of string will not affect the original string . It usually returns a new string .
capitalize String case conversion
s = "python"
s1 = s.capitalize()
print(s1)
title Capitalize the first letter of a word
s = "I have a dream!"
s1 = s.title() # Capitalize the first letter of a word
print(s1)
lower To lower case letters
s = "I HAVE A DREAM"
s1 = s.lower() # To lower case letters
print(s1)
upper Turn all letters into capital letters
s = "i have a dream"
s1 = s.upper() # Turn all letters into capital letters
print(s1)
How to ignore case to judge => upper(), Case implementation ignores the case of English input verification code :
verify_code = "xAd1"
user_input = input(f" Please enter the verification code ({
verify_code}): ")
if verify_code.upper() == user_input.upper():
print(" The verification code is correct ")
else:
print(" The verification code is incorrect ")
summary :
String operation does not change the original string .
capitalize String case conversion
title Capitalize the first letter of a word
lower To lower case letters
upper Turn all letters into capital letters
边栏推荐
猜你喜欢
随机推荐
Starfish OS:以现实为纽带,打造元宇宙新范式
[C language] file related operations
【LeetCode】29、 两数相除
[daily question] 1260 2D mesh migration
Opportunities and challenges coexist for financial enterprises to go to sea in emerging markets, advance AI ensures its safety and compliance development
Web3流量聚合平台Starfish OS,诠释真正商业的“P2E”生态
Web3流量聚合平台Starfish OS,给玩家元宇宙新范式体验
asp.net -GridView自带的删除行项超链接用法(DeleteButton)
How to solve the garbled Chinese annotation of idea import project
Oufeiguang: optical lenses / image modules such as sports cameras and smart homes have been deployed, and some products have been mass produced
项目总结:文件管理系统
第二章第十一节:元组
巧用RoaringBitMap处理海量数据内存diff问题
3D转换之三维坐标系,透视旋转等基础知识
广发期货网上开户安全吗?有没有开户指引?
【小程序】快来开发你的第一个微信小游戏(详细流程)
面试中常见的的 web 安全问题
Kingbasees database administrator's Guide -- 12 management of schema objects
长城证券手机软件线上炒股开户证券公司佣金低?开户安全吗?
DevExpress XtraReport报表开发相关知识点