上一页 1 ··· 187 188 189 190 191 192 193 194 195 ··· 403 下一页
摘要: 001、 >>> test = [("a",100), ("b", 200), ("c", 300)] >>> test [('a', 100), ('b', 200), ('c', 300)] >>> dict(test) ## 列表转换为字典 {'a': 100, 'b': 200, 'c': 阅读全文
posted @ 2022-08-13 16:14 小鲨鱼2018 阅读(425) 评论(0) 推荐(0)
摘要: 001、 #include <stdio.h> #define NUMBER 5 // 此处为对象式宏, 运行程序时, main函数体内的NUMBER将被替换为5 int main(void) { int i; int tensu[NUMBER]; int sum = 0; printf("plea 阅读全文
posted @ 2022-08-13 00:45 小鲨鱼2018 阅读(56) 评论(0) 推荐(0)
摘要: 001、 #include <stdio.h> #define NUMBER 7 int main(void) { int i, temp; int array[NUMBER]; puts("please input the arrays."); for(i = 0; i < NUMBER; i++ 阅读全文
posted @ 2022-08-13 00:37 小鲨鱼2018 阅读(181) 评论(0) 推荐(0)
摘要: 001、 #include <stdio.h> int main(void) { int i; puts("please input an positive num."); printf("i = "); scanf("%d", &i); while (i > 0) { printf("%d", i 阅读全文
posted @ 2022-08-12 22:04 小鲨鱼2018 阅读(166) 评论(0) 推荐(0)
摘要: 001、c语言中字符常量用单引号括起来, 用putchar函数输出。 字符常量是 int类型。 字符常量为什么是int型? #include <stdio.h> int main(void) { int i; for (i = 1; i <= 5; i++) { putchar('*'); ## 单 阅读全文
posted @ 2022-08-12 20:48 小鲨鱼2018 阅读(580) 评论(0) 推荐(0)
摘要: 001、 >>> dict1 = {"d":400, "a":300, "e":500, "b":700, "c":600} ## 测试字典 >>> dict1 {'d': 400, 'a': 300, 'e': 500, 'b': 700, 'c': 600} >>> sorted(dict1.k 阅读全文
posted @ 2022-08-12 20:15 小鲨鱼2018 阅读(115) 评论(0) 推荐(0)
摘要: 001、 >>> test = [10, 20, 10, 30, 30, 10, 40, 10, 30] ## 测试列表 >>> from collections import Counter as ct ## 借助Counter函数实现 >>> ct(test) Counter({10: 4, 3 阅读全文
posted @ 2022-08-12 17:33 小鲨鱼2018 阅读(151) 评论(0) 推荐(0)
摘要: 001、 >>> import re >>> str = "sefderfhjuynb" >>> re.findall(".{3}", str) ## 步长为3 ['sef', 'der', 'fhj', 'uyn'] >>> re.findall(".{2}", str) ## 步长为2 ['se 阅读全文
posted @ 2022-08-12 17:19 小鲨鱼2018 阅读(236) 评论(0) 推荐(0)
摘要: 001、 root@PC1:/home/test2# ls test.py root@PC1:/home/test2# cat test.py ## 测试程序 #!/usr/bin/python out_file = open("result.txt", "w") for i in range(1, 阅读全文
posted @ 2022-08-12 16:41 小鲨鱼2018 阅读(261) 评论(0) 推荐(0)
摘要: 001、 continue表示跳过后面的程序,重新循环,而pass表示站位,什么也不做,后面的代码(else之前)还是会执行, 好多情况下是没有想清楚这部分应该怎么写,所以先用pass站位,能让程序顺利跑起来。等想好这部分怎么写了,再替换掉pass部分 root@PC1:/home/test2# l 阅读全文
posted @ 2022-08-12 15:57 小鲨鱼2018 阅读(382) 评论(0) 推荐(0)
上一页 1 ··· 187 188 189 190 191 192 193 194 195 ··· 403 下一页