02 2024 档案
摘要:python# 假设向程序提供了以下输入:8 然后输出应为:40320
阅读全文
摘要:#编写一个程序,查找所有此类数字,它们可以被7整除,但不能是5的倍数(在2000和3200之间(均包括在内))。# 获得的数字应以逗号分隔的顺序打印在一行上。s=[]for i in range(2000,3201): if(i %7==0) and (i%5!=0): s.append(i)pri
阅读全文
摘要:# 将字符串 a = “ welcome to my world ”首尾空格去掉a=" welcome to my world "print(a.strip())
阅读全文
摘要:# 输入一个姓名,判断是否姓王。name=input("请输入姓名")if name[0] =="王": print("姓王")else: print("不姓王")
阅读全文
摘要:#判断字符串 a = “welcome to my world” 是否包含单词 b = “world”,包含返回 True,不包含返回 Falsedef test(): a = "welcome to my world" b="world" if b in a: return True else:
阅读全文
摘要:#打印字符串中,指定的字符出现的次数 str="56rtyrtyrtertert"s="t"print(str.count(s))
阅读全文
摘要:#找出单词 “linda” 在字符串“welcome to my world,linda.” 中出现的位置,找不到返回 -1。#def test(): str = "welcome to my world,linda" a = "linda" if a in str: return str.find
阅读全文
摘要:#打印除当前日期时间import datetimeprint(datetime.datetime.now())
阅读全文
摘要:#打印1-100随机10个整数import randomfor i in range(3): a=random.randint(1,101) print(a)
阅读全文
摘要:#将文件1的内容-复制到文件2with open("sunlin.txt","r")as f1: with open("linda.txt","w")as f2: content=f1.read() f2.write(content)
阅读全文
摘要:1:在python相关路径内创建个文件 2:read读取即可 with open("sunlin.txt")as f: content=f.read() print(content)
阅读全文
摘要:for i in range(0,5): print("*"*(i+1))
阅读全文
摘要:
阅读全文
摘要:count()函数即可解决a="xrctvgybxrcftvgybcvtgybhcrvtrfgbcv"print(a.count("x"))
阅读全文