摘要: 1、反转 永久反转 >>> test1 ['aa', 'bb', 'aa', 'cc', 'aa', 'cc', 'dd', 'xx', 'bb'] >>> test1.reverse() >>> test1 ['bb', 'xx', 'dd', 'cc', 'aa', 'cc', 'aa' 阅读全文
posted @ 2021-04-28 21:35 小鲨鱼2018 阅读(256) 评论(0) 推荐(0) 编辑
摘要: python中返回列表中指定元素的所有索引。 1、基本用法 >>> test1 ['aa', 'bb', 'aa', 'cc', 'aa', 'cc', 'dd', 'xx', 'bb'] >>> test1.index("aa") 0 2、返回所有索引 >>> test1 ['aa', 'bb', 阅读全文
posted @ 2021-04-28 21:22 小鲨鱼2018 阅读(2975) 评论(0) 推荐(0) 编辑
摘要: python中返回列表元素的每一个元素的频数。 1、单个元素频数 >>> test1 ['aa', 'bb', 'aa', 'cc', 'aa', 'cc', 'dd', 'xx', 'bb'] >>> test1.count("aa") 3 2、 >>> test1 ['aa', 'bb', 'a 阅读全文
posted @ 2021-04-28 20:55 小鲨鱼2018 阅读(234) 评论(0) 推荐(0) 编辑
摘要: python中列表元素的去重复 1、方法1 >>> test1 = ["aa","bb","aa","cc","aa","cc","dd","xx","bb"] >>> test1 ['aa', 'bb', 'aa', 'cc', 'aa', 'cc', 'dd', &# 阅读全文
posted @ 2021-04-28 20:35 小鲨鱼2018 阅读(241) 评论(0) 推荐(0) 编辑
摘要: python中列表的连接操作符、重复操作符、成员关系操作符。 1、连接操作符,相当于列表对象extend >>> test1 = ["aa","bb"] >>> test1 ['aa', 'bb'] >>> test2 = ["cc","dd"] >>> test2 ['cc', 'dd'] >>> 阅读全文
posted @ 2021-04-28 20:31 小鲨鱼2018 阅读(443) 评论(0) 推荐(0) 编辑
摘要: python中列表切片。 1、基本用法 >>> test1 [11, 22, 33, 44, 55, 66, 77, 88, 99, 0] >>> test1[2:5] [33, 44, 55] 2、 >>> test1 [11, 22, 33, 44, 55, 66, 77, 88, 99, 0] 阅读全文
posted @ 2021-04-28 20:14 小鲨鱼2018 阅读(201) 评论(0) 推荐(0) 编辑
摘要: python中从列表中删除元素 remove:删除指定元素 pop:删除特定索引位置元素 del:删除变量 1、remove >>> test1 = ["aa","bb","cc","dd","ee","ff","gg"] >>> test1 ['aa', 'bb', 'cc', 'dd', 'ee 阅读全文
posted @ 2021-04-28 19:37 小鲨鱼2018 阅读(619) 评论(0) 推荐(0) 编辑
摘要: 1、抽取一个随机数 >>> import random >>> random.randint(1,10) 3 >>> random.randint(1,10) 9 >>> random.randint(1,10) 3 2、从序列(列表、元组、字符串)中随机抽取一个元素 >>> test1 = ["a 阅读全文
posted @ 2021-04-28 19:30 小鲨鱼2018 阅读(1758) 评论(0) 推荐(0) 编辑
摘要: python中向列表中添加元素 append、追加一个元素 extend、扩展多个元素 insert、插入一个元素。 1、append >>> test1 = ["aaa","bbb","ccc"] >>> test1 ['aaa', 'bbb', 'ccc'] >>> test1.append(" 阅读全文
posted @ 2021-04-28 18:01 小鲨鱼2018 阅读(930) 评论(0) 推荐(0) 编辑
摘要: python中for、while语句计算1-100的和。 1、for语句 1-100的和 >>> sum = 0 >>> for i in range(1,101): sum += i >>> print(sum) 5050 >>> 1-100内偶数的和 >>> sum = 0 >>> for i 阅读全文
posted @ 2021-04-28 15:43 小鲨鱼2018 阅读(4209) 评论(0) 推荐(0) 编辑
摘要: 1、原始游戏 (input 内建函数用于接收用户输入) temp = input("please input an integer:") guess = int(temp) if guess == 8: print("you are right!") print("no gift evec thou 阅读全文
posted @ 2021-04-28 15:23 小鲨鱼2018 阅读(1044) 评论(0) 推荐(0) 编辑
摘要: python中原始字符串和长字符串 1、原始字符串 >>> string="c:\now" >>> string 'c:\now' >>> print(string) ## \n被解释为换行符 c: ow >>> 在字符串前添加r,表示原始字符串 >>> string = r"c:\now" >>> 阅读全文
posted @ 2021-04-28 15:18 小鲨鱼2018 阅读(249) 评论(0) 推荐(0) 编辑
摘要: c语言中程序的循环控制 大小值的判断及赋值。 输出长度大于高度的矩形。 1、 #include <stdio.h> int main(void) { int i, j, height, width, min, max; printf("please input the height and widt 阅读全文
posted @ 2021-04-28 10:07 小鲨鱼2018 阅读(266) 评论(0) 推荐(0) 编辑
摘要: 1、显示所有的小于输入的整数的所有2的乘方 while语句: #include <stdio.h> int main(void) { int i = 2, j; puts("please input an integer."); printf("j = "); scanf("%d", &j); wh 阅读全文
posted @ 2021-04-28 09:44 小鲨鱼2018 阅读(220) 评论(0) 推荐(0) 编辑