
Python
崽崽张不是奶t
崽崽张
展开
-
井字棋游戏
井字棋游戏原创 2022-10-26 17:10:30 · 1128 阅读 · 0 评论 -
【文字游戏之猜单词】
文字游戏:1.玩家1挑选一个秘密单词,单词中有多少个字母则画多少个下划线2.玩家二每猜一个字母,若正确则将下划线改为字符,若同一字母出现两次则需要猜测两次3.玩家二共有单词长度+3次机会,若猜测正确则玩家二胜利,否则玩家1胜利words=input("please input one secret words")words1=wordslines=[]while len(lines)<len(words): lines.append("_")count=0while coun原创 2022-05-20 12:03:51 · 288 阅读 · 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 · 118 阅读 · 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 · 112 阅读 · 0 评论 -
【列 表】
初始化list_one=[1,4,2,4,9,8]list_two=["Chenduoduo","Wuyanlin"]列表增加#末尾增加元素list_one.append(520)#指定下标位置增加元素list_one.insert(0,1314)#将列表2追加至列表1list_one.extend(list_two)列表删除#删除指定下标位置的数据del list_one[0]#删除第一个出现的指定数据list_one.remove(2)#删除列表最后一个元素list_原创 2022-05-13 22:25:34 · 133 阅读 · 0 评论