笔记
while(true).
这个作者很懒,什么都没留下…
展开
-
字符串基础 “ “
居中poem = ["\t\n登鹳雀楼", "王之涣", "白日依山尽\t\n", "黄河入海流", "欲穷千里目", "更上一层楼"]for poem_str in poem : #先用strip方法去除字符串中的空白字符,再用center方法居中显示文本 #center内容中" " 中文状态下的空格来做fillchar print("|%s|" % poem_str.strip().cente原创 2022-02-23 12:58:00 · 287 阅读 · 0 评论 -
字典 基础{}
定义——键值对(笔记第四天){索引 : 值 ,}xiaoming = {"name" : "小明" , "age" : 18 , "gender" : True , "height" : 1.85}原创 2022-02-23 12:55:45 · 119 阅读 · 0 评论 -
元组 基础()
基础操作 ()①元组中的数据无法修改。#空元组#info_tuple = ()#只含有一个元素---加一个逗号#info_tuple = (5,)#取值和取索引info_tuple = ("zhangsan" , 1 , 2)print(info_tuple[0])# 和列表一样 取值用中括号#已经知道内容 需要知道索引数↓print(info_tuple.index("zhangsan"))#统计次数 元组.count(数据)#统计个数 len(元组)循环遍历同列表,原创 2022-02-21 21:37:35 · 257 阅读 · 0 评论 -
Python列表基础
定义和增删改查#定义列表 用一对中括号name_list = ["张三" , "李四" , "王五"]#取列表第一个元素的值,以此类推print(name_list[0])#修改元素 列表[索引] = 数据name_list[0] = ["zhangsan"]"""增加元素1.列表.insert(索引,数据) 在指定索引处添加数据2.列表.append(数据) 在末尾追加数据3.列表.extend(列表2) 在末尾追加列表2的数据"""num_list = [1,4,6原创 2022-02-19 16:12:49 · 517 阅读 · 0 评论 -
函数基础部分
定义函数#定义函数def triple(): row = 1 while row <= 9: col = 1 while col <= row : print("%d * %d = %d" %(col ,row, col*row), end="\t") col += 1 print("") row += 1print("九九乘法表")#调用函数显示效果原创 2022-02-18 16:04:15 · 145 阅读 · 0 评论 -
Python基础
猜拳"""1.利用random随机生成电脑出的拳 再用input导入玩家的选择2.if、elif、else的应用"""import randomplayer = int(input("请输入你的选择:1——石头 2——剪刀 3——布"))computer = random.randint(1,3)print("玩家出的是%d,电脑出的是%d" %(player , computer))if((player == 1 and computer == 2) or (pla原创 2022-02-18 15:56:03 · 201 阅读 · 0 评论