摘要: # 将字符串 a = “ welcome to my world ”首尾空格去掉a=" welcome to my world "print(a.strip()) 阅读全文
posted @ 2024-02-20 18:19 琳达的博客 阅读(69) 评论(0) 推荐(0) 编辑
摘要: # 输入一个姓名,判断是否姓王。name=input("请输入姓名")if name[0] =="王": print("姓王")else: print("不姓王") 阅读全文
posted @ 2024-02-20 17:05 琳达的博客 阅读(197) 评论(0) 推荐(0) 编辑
摘要: #判断字符串 a = “welcome to my world” 是否包含单词 b = “world”,包含返回 True,不包含返回 Falsedef test(): a = "welcome to my world" b="world" if b in a: return True else: 阅读全文
posted @ 2024-02-20 16:52 琳达的博客 阅读(75) 评论(0) 推荐(0) 编辑
摘要: #打印字符串中,指定的字符出现的次数 str="56rtyrtyrtertert"s="t"print(str.count(s)) 阅读全文
posted @ 2024-02-20 11:17 琳达的博客 阅读(21) 评论(0) 推荐(0) 编辑
摘要: #找出单词 “linda” 在字符串“welcome to my world,linda.” 中出现的位置,找不到返回 -1。#def test(): str = "welcome to my world,linda" a = "linda" if a in str: return str.find 阅读全文
posted @ 2024-02-20 11:13 琳达的博客 阅读(5) 评论(0) 推荐(0) 编辑