![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Python
崽崽张不是奶t
崽崽张
展开
-
井字棋游戏
井字棋游戏原创 2022-10-26 17:10:30 · 1050 阅读 · 0 评论 -
【文字游戏之猜单词】
文字游戏: 1.玩家1挑选一个秘密单词,单词中有多少个字母则画多少个下划线 2.玩家二每猜一个字母,若正确则将下划线改为字符,若同一字母出现两次则需要猜测两次 3.玩家二共有单词长度+3次机会,若猜测正确则玩家二胜利,否则玩家1胜利 words=input("please input one secret words") words1=words lines=[] while len(lines)<len(words): lines.append("_") count=0 while coun原创 2022-05-20 12:03:51 · 199 阅读 · 0 评论 -
【字符串】
初始化 str1=" Chenduoduo " str2="Wuyanlin" 常用操作 #获取字符串长度 len(str1) #返回duo在字符串中出现的次数 str1.count("duo") #返回duo在字符串中第一次出现的索引位置 str1.index("duo") #取字符串中的单个字符 str1[0] #默认删除收尾空白符 str1.strip() #切片 str1[5:] #成员运算符 "duo" in srt1 "duo" not in str1 #原始字符串,强制不转义 r"\原创 2022-05-14 07:16:23 · 70 阅读 · 0 评论 -
【元组 字典】
元组索引值从0开始,由()表示,元组中只包含一个元素时需要在元素后面添加逗号 tuple_one=() tuple_two=("Chenduoduo",) tuple_three=("Chen","duo","duo",) len(tuple_two) tuple_three.count("duo") tuple_three.index("duo") 字典通常存储描述一个物体的信息,用{},采用键值对 字典输出 Info_Chen={"name":"Chenduoduo","birth":0125,"s原创 2022-05-13 22:52:15 · 70 阅读 · 0 评论 -
【列 表】
初始化 list_one=[1,4,2,4,9,8] list_two=["Chenduoduo","Wuyanlin"] 列表增加 #末尾增加元素 list_one.append(520) #指定下标位置增加元素 list_one.insert(0,1314) #将列表2追加至列表1 list_one.extend(list_two) 列表删除 #删除指定下标位置的数据 del list_one[0] #删除第一个出现的指定数据 list_one.remove(2) #删除列表最后一个元素 list_原创 2022-05-13 22:25:34 · 90 阅读 · 0 评论