上一页 1 2 3 4 5 6 ··· 8 下一页
摘要: # 将字符串 a = “ welcome to my world ”首尾空格去掉a=" welcome to my world "print(a.strip()) 阅读全文
posted @ 2024-02-20 18:19 琳达的博客 阅读(191) 评论(0) 推荐(0)
摘要: # 输入一个姓名,判断是否姓王。name=input("请输入姓名")if name[0] =="王": print("姓王")else: print("不姓王") 阅读全文
posted @ 2024-02-20 17:05 琳达的博客 阅读(427) 评论(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 琳达的博客 阅读(170) 评论(0) 推荐(0)
摘要: #打印字符串中,指定的字符出现的次数 str="56rtyrtyrtertert"s="t"print(str.count(s)) 阅读全文
posted @ 2024-02-20 11:17 琳达的博客 阅读(43) 评论(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 琳达的博客 阅读(23) 评论(0) 推荐(0)
摘要: #打印除当前日期时间import datetimeprint(datetime.datetime.now()) 阅读全文
posted @ 2024-02-19 17:58 琳达的博客 阅读(9) 评论(0) 推荐(0)
摘要: #打印1-100随机10个整数import randomfor i in range(3): a=random.randint(1,101) print(a) 阅读全文
posted @ 2024-02-19 17:37 琳达的博客 阅读(386) 评论(0) 推荐(0)
摘要: #将文件1的内容-复制到文件2with open("sunlin.txt","r")as f1: with open("linda.txt","w")as f2: content=f1.read() f2.write(content) 阅读全文
posted @ 2024-02-19 16:48 琳达的博客 阅读(47) 评论(0) 推荐(0)
摘要: 1:在python相关路径内创建个文件 2:read读取即可 with open("sunlin.txt")as f: content=f.read() print(content) 阅读全文
posted @ 2024-02-19 16:11 琳达的博客 阅读(19) 评论(0) 推荐(0)
摘要: for i in range(0,5): print("*"*(i+1)) 阅读全文
posted @ 2024-02-19 14:46 琳达的博客 阅读(191) 评论(0) 推荐(0)
上一页 1 2 3 4 5 6 ··· 8 下一页