当前位置: 首页 > news >正文

农业行业网站模板移动网站 pc网站的区别吗

农业行业网站模板,移动网站 pc网站的区别吗,清空回收站 wordpress,外贸网站经典营销案例文章目录 专栏导读1、拼接字符串2、获取字符串长度3、字符串切片4、字符串替换#xff1a;5、字符串分割6、字符串查找7、字符串大小写转换8、字符串去除空白9、字符串格式化#xff1a;10、字符串编码与解码#xff1a;11、字符串判断12、字符串填充与对齐总结 专栏导读 5、字符串分割6、字符串查找7、字符串大小写转换8、字符串去除空白9、字符串格式化10、字符串编码与解码11、字符串判断12、字符串填充与对齐总结 专栏导读 本文已收录于《30天学习Python从入门到精通》 本专栏专门针对于零基础和需要重新复习巩固的同学所准备的一套基础班教学从0基础到精通Python轻松掌握Python欢迎各位同学订阅专栏订阅地址点我直达 此外如果您已工作如需利用Python解决办公中常见的问题欢迎订阅《Python办公自动化》专栏订阅地址点我直达 1、拼接字符串 ①使用加号 ②使用join()方法 s1 Hello s2 World s3 s1 s2 # Hello World s4 .join([s1, s2]) # Hello World print(s3) print(s4)2、获取字符串长度 使用len()函数 s Hello length len(s) # 5 print(length)3、字符串切片 使用[start:stop:step]语法 [首:尾:步长]以前当老师的时候这里我总是教取头不取尾要是想取到尾尾1 s HelloWorld substring s[0:5] # Hello substring_with_step s[0:10:2] # HloW print(substring) print(substring_with_step)4、字符串替换 使用replace()方法 s Hello World new_s s.replace(World, Python) # Hello Python print(new_s)5、字符串分割 使用split()方法 s Hello,World,Python words s.split(,) # [Hello, World, Python] print(words)6、字符串查找 使用find(), index(), count()等方法 s Hello World index s.find(World)# 返回开始的第一个索引 count s.count(o) # 返回出现的次数 print(index, count)7、字符串大小写转换 使用upper(), lower(), capitalize(), title()等方法 s hello world s_upper s.upper() # 全部字母大写 print(s_upper)s2 HELLO WORLD s_lower s2.lower() # 全部字母大写 print(s_lower)s_capitalize s.capitalize()# 首字母大写 print(s_capitalize)s_title s.title()# 每个单词首字母大写 print(s_title)8、字符串去除空白 使用strip(), lstrip(), rstrip()等方法 # 字符串去除空白 # 使用strip(),去除所有空格 # lstrip(),去除左边空格 # rstrip()去除右边空格 str hello world print(str.strip()) print(str.lstrip()) print(str.rstrip())9、字符串格式化 使用str.format()方法 使用f-stringPython 3.6 name Alice age 30 formatted_string My name is {} and I am {} years old..format(name, age) formatted_fstring fMy name is {name} and I am {age} years old. print(formatted_string) print(formatted_fstring)10、字符串编码与解码 使用encode()和decode()方法 s Hello encoded s.encode(utf-8) # bytes 对象 decoded encoded.decode(utf-8) # Hello print(encoded) print(decoded)11、字符串判断 使用startswith(), endswith(), isalpha(), isdigit(), isalnum(), isspace()等方法 s Hello123 is_start_with_hello s.startswith(Hello) # 判断字符串是否以Hello开头 is_digit s.isdigit() # 判断字符串是否全为数字 is_alpha s.isalpha() # 判断字符串是否全为字母 is_alnum s.isalnum() # 判断字符串是否全为字母和数字 is_space s.isspace() # 判断字符串是否全为空格 print(is_start_with_hello) print(is_digit) print(is_alpha) print(is_alnum) print(is_space)12、字符串填充与对齐 使用ljust(), rjust(), center(), zfill()等方法 # 使用ljust(), rjust(), center(), zfill()等方法 s Hello print(s.ljust(10,-)) # 字符在左边右边以’-‘填充一共长度为10 print(s.rjust(10,-)) # 字符在右边左边以’-‘填充一共长度为10 print(s.center(10,-)) # 填充10个空格在中间 print(s.zfill(10)) # 填充10个0在左边总结 希望对初学者有帮助 致力于办公自动化的小小程序员一枚 希望能得到大家的【一个免费关注】感谢 求个 关注 此外还有办公自动化专栏欢迎大家订阅Python办公自动化专栏 求个 ❤️ 喜欢 ❤️ 此外还有爬虫专栏欢迎大家订阅Python爬虫基础专栏 求个 收藏 此外还有Python基础专栏欢迎大家订阅Python基础学习专栏
http://www.w-s-a.com/news/195456/

相关文章:

  • 古交市网站建设公司apk连接wordpress
  • 网页 网 址网站区别wordpress菜单居右
  • 网站建设搭建运营一台云服务器做多个网站
  • 用php做网站用什么框架推广网站推荐
  • 如何用二级域名做网站多用户网上商城
  • 河南省建设科技网站浅谈电子商务网站建设与规划
  • 网站空间需要续费青海网站建设推广
  • 网站开发本地环境企业网站建设排名口碑
  • 做新闻的网站怎样赚钱个人网站课程设计报告
  • 网站设计样例那个网站做图片好看
  • 小型公司网站建设深圳网络营销策划有限公司
  • 国内优秀企业网站做视频网站用什么系统
  • 网站建设入门pdfwordpress网站标题
  • 专业网站的定义网站运营的概念
  • 外贸服装网站建设网页美工设计说明书
  • 郑州专业做网站公百度翻译api wordpress
  • 做网站哪里找大学的一级或二级域名
  • 没有静态ip可以做网站服务器上饶网站制作需要多少钱
  • 网站建设wangzhii做国外网站做什么内容
  • 网站建设 搞笑笑话经典 wordpress主题下载
  • 做网站要懂哪些wordpress 站点网络
  • 郑州外贸网站建设公司排名网站设计做啥好
  • 网站开发合同付款比例wordpress调用指定文章内容
  • 湖北平台网站建设哪里好辽宁建设工程信息网官网平台
  • 公司优化是什么意思?洛阳seo博客
  • 普通建站网站首页制作模板
  • 江苏城乡与住房建设厅网站wordpress 添加导航
  • 免费单页网站在线制作网站制作与网站建设pdf
  • 网站开发使用云数据库技术教程大连模板开发建站
  • 佘山网站建设创造网站需要多少钱