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

做汽车商城网站好用的做微信公众号的网站

做汽车商城网站,好用的做微信公众号的网站,淄博做网站的网络公司,六安网1. 字符串 (1) 字符串能通过下标索引来获取其中的元素 (2) 旧字符串无法修改特定下标的元素 (3) index——查找字符串中任意元素在整个字符串中的起始位置(单个字符或字符串都可以) tmp_str "supercarrydoinb" tmp_position1 tmp_str.index("s") tmp_p…

1. 字符串

(1) 字符串能通过下标索引来获取其中的元素

(2) 旧字符串无法修改特定下标的元素

(3) index——查找字符串中任意元素在整个字符串中的起始位置(单个字符或字符串都可以)

tmp_str = "supercarrydoinb"
tmp_position1 = tmp_str.index("s")
tmp_position2 = tmp_str.index("doinb")
print(f"{tmp_position1}, {tmp_position2}")

(4) replace——将原字符串中部分字符串1改为字符串2,生成一个新的字符串,不修改原字符串

tmp_str = "supercarrydoinb"
tmp_str1 = tmp_str.replace("doinb", "666")
print(f"{tmp_str1}")

(5) split——将字符串通过字符串中的子分割字符串分割成多个字符串存储到列表中,返回列表名

tmp_str = "super carry doinb"
tmp_str1 = tmp_str.split(" ")
print(f"{tmp_str1}")

(6) strip

        1.   字符串.strip()

                去除字符串前后的空格或回车符,将结果返回给新的字符串

tmp_str = (" super carry doinb ")
tmp_str1 = tmp_str.strip()
print(f"{tmp_str1}")

        2. 字符串.strip(字符串1)

                去除字符串前后的字符串1,将结果返回给新的字符串

tmp_str = ("qwesuper carry doinbewq")
tmp_str1 = tmp_str.strip("qwe")
print(f"{tmp_str1}")

        注意:对于strip中加参数,比如参数是ab,是分别去除a和b,而不是直接去除ab,非整体去除

(7) count——计算字符串中某个字符或部分字符串在整个字符串中的个数

tmp_str = (" super carry doinb ")
tmp_cnt = tmp_str.count("do")
print(f"{tmp_cnt}")

(8) len——计算字符串中字符的个数

tmp_str = ("supercarrydoinb")
tmp_len = len(tmp_str)
print(f"{tmp_len}")

(9) while循环 

tmp_str = ("supercarrydoinb")
tmp_cnt = 0
while tmp_cnt < len(tmp_str):print(f"{tmp_str[tmp_cnt]}")tmp_cnt += 1

(10) for循环

tmp_str = ("supercarrydoinb")
for i in tmp_str:print(f"{i}")

(11) 字符串特点

        字符串只能存储字符类型,且不可被修改

(12) 练习

tmp_str = ("super carry doinb")
tmp_count = tmp_str.count("super")
print(f"{tmp_count}")
tmp_str1 = tmp_str.replace(" ", "|")
print(f"{tmp_str1}")
tmp_str2 = tmp_str1.split("|")
print(f"{tmp_str2}")

        

http://www.yayakq.cn/news/472510/

相关文章:

  • 帮你做海报网站微信公众号这么创建
  • 电子商务软件网站建设的核心wordpress淘宝客插件开发
  • 跟男友做网站天津住房与城乡建设厅网站首页
  • 扬州建设企业网站做电商一个月可以赚多少钱
  • 广西建设局网站首页网站建设之家
  • 免费网站建设的html网页制作实例代码
  • iis怎么做网站网站怎么做来卖东西
  • 楼盘动态怎么seo快速排名
  • 速贝cms建站系统wordpress liuweili
  • 高端定制网站开发设计建站流程网站排名易下拉稳定
  • 玛丁图商城网站开发网站流量怎么挣钱
  • zenm自己做网站免费网站建站2773
  • h5电子商城网站开发网站快速排名互点软件
  • 招聘 负责网站开发网页上传和网站开发
  • 深圳网站设计公司wx成都柚米科技15html网页制作app手机版
  • 广州网站建设484186wordpress 注册 邮件
  • 一个域名访问不同的网站莱州网站设计
  • 高速公路建设管理局网站下载做蛋糕网站
  • 做交易网站需要多少钱上海人才网官网还是上海市人才网
  • ppt做视频模板下载网站有哪些内容做秩序册的网站
  • 单页加盟网站模板黄冈论坛网站有哪些
  • 如何推荐别人做网站南昌地宝网分类
  • 盘锦做网站专家平台推广费用
  • 怎么把自己做的网站发布出去网站建设微商城
  • django做的购物网站国内永久免费云服务器
  • 最好的网站开发平台个人网站需要什么页面
  • 嘉兴做网站多少钱.net网站开发教程百度贴吧
  • wordpress 自定义页面 模版网站优化的作用
  • 海宁做网站的公司wordpress指定模板
  • 网站开发学哪些网络游戏网站开发