摘要: python中字符串拼接的三种方法。 1、加号拼接 >>> a = "abcd" >>> b = "xyzm" >>> a 'abcd' >>> b 'xyzm' >>> a + b 'abcdxyzm' 2、join拼接 >>> c = ["abcd","xyzm"] >>> c ['abcd', 阅读全文
posted @ 2021-05-01 23:16 小鲨鱼2018 阅读(599) 评论(0) 推荐(0) 编辑
摘要: python中字符串的格式化。 1、format 位置参数 >>> "{0} and {1}".format("aaa","bbb") 'aaa and bbb' >>> "{0},{1} and {2}".format("aaa","bbb","ccc") 'aaa,bbb and ccc' 关键 阅读全文
posted @ 2021-05-01 23:11 小鲨鱼2018 阅读(142) 评论(0) 推荐(0) 编辑
摘要: python中字符串的拼接。 1、 >>> test1 = ["aaa","bbb","ccc","ddd","eee"] >>> test1 ['aaa', 'bbb', 'ccc', 'ddd', 'eee'] >>> "-".join(test1) 'aaa-bbb-ccc-ddd-eee' 阅读全文
posted @ 2021-05-01 22:56 小鲨鱼2018 阅读(64) 评论(0) 推荐(0) 编辑
摘要: 1、问题 [root@centos7 Python-3.9.4]# ln -s python /usr/bin/python [root@centos7 Python-3.9.4]# python -bash: /usr/bin/python: Too many levels of symbolic 阅读全文
posted @ 2021-05-01 22:52 小鲨鱼2018 阅读(2969) 评论(0) 推荐(0) 编辑
摘要: python中拆分字符串 1、 >>> test1 = "abxcdxefxfh" >>> test1 'abxcdxefxfh' >>> test1.split(sep = "x") ['ab', 'cd', 'ef', 'fh'] 阅读全文
posted @ 2021-05-01 21:51 小鲨鱼2018 阅读(381) 评论(0) 推荐(0) 编辑
摘要: python中替换字符串中特定字符。 1、 >>> test1 = "abdadcadadfa" >>> test1 'abdadcadadfa' >>> test1.replace("a","x") 'xbdxdcxdxdfx' >>> test1.replace("a","x",2) ## 指定 阅读全文
posted @ 2021-05-01 21:48 小鲨鱼2018 阅读(2657) 评论(0) 推荐(0) 编辑
摘要: 1、返回第一个出现的索引 >>> test1 'absacaxy' >>> test1.find("a") 0 2、返回特定字符的所有索引 >>> test1 'absacaxy' >>> b = test1.count("a") >>> c = -1 >>> for i in range(b): 阅读全文
posted @ 2021-05-01 21:34 小鲨鱼2018 阅读(3760) 评论(0) 推荐(0) 编辑
摘要: python中查找字符串中字符出现的次数 1、 >>> test1 = "absacaxy" >>> test1.count("a") 3 >>> test1.count("a",0,4) ## 设置查找范围 2 2、统计所有字符出现的次数 >>> test1 = "abdeaceb" >>> a 阅读全文
posted @ 2021-05-01 21:27 小鲨鱼2018 阅读(2029) 评论(0) 推荐(0) 编辑
摘要: 1、 删除左边空白 >>> test1 = " abcd " >>> test1 ' abcd ' >>> test1.lstrip() 'abcd ' 2、删除右边空白 >>> test1 ' abcd ' >>> test1.rstrip() ' abcd' 3、删除两边空白 >>> test1 阅读全文
posted @ 2021-05-01 21:20 小鲨鱼2018 阅读(687) 评论(0) 推荐(0) 编辑
摘要: 1、大写改为小写 >>> test1 = "abCDEfg" >>> test1 'abCDEfg' >>> test1.upper() 'ABCDEFG' 2、小写变大写 >>> test1 'abCDEfg' >>> test1.lower() 'abcdefg' >>> test1 'abCD 阅读全文
posted @ 2021-05-01 21:14 小鲨鱼2018 阅读(667) 评论(0) 推荐(0) 编辑
摘要: python中zip函数 1、python中zip函数用于返回由可迭代参数共同组成的元组。 长度不一致时,以短的序列进行迭代。 >>> test1 = ["aaa","bbb","ccc","ddd"] >>> test2 = (111,222,333,444,555) >>> test3 = "a 阅读全文
posted @ 2021-05-01 20:44 小鲨鱼2018 阅读(596) 评论(0) 推荐(0) 编辑
摘要: python中enumerate函数。 1、python中enumerate函数 enumerate函数的应用对象为序列(列表、元组、字符串), 返回一个由二元组组成的可迭代对象,二元组由可迭代参数的索引号及其对应的元素组成。 列表 >>> test1 = ["aaa","bbb","ccc"] > 阅读全文
posted @ 2021-05-01 20:37 小鲨鱼2018 阅读(558) 评论(0) 推荐(0) 编辑
摘要: 1、 #include <stdio.h> int main(void) { int i, j, k, a[2][4][3], b[4][3] = {}; for(i = 0; i < 2; i++) { for(j = 0; j < 4; j++) { for(k = 0; k < 3; k++) 阅读全文
posted @ 2021-05-01 18:26 小鲨鱼2018 阅读(50) 评论(0) 推荐(0) 编辑
摘要: 1、 #include <stdio.h> int main(void) { int i, j, a[8][3] = {}; puts("please input the scores of the students."); for(i = 0; i < 6; i++) { for(j = 0; j 阅读全文
posted @ 2021-05-01 17:30 小鲨鱼2018 阅读(48) 评论(0) 推荐(0) 编辑
摘要: 求3行4列矩阵和4行5列矩阵的乘积。 1、 #include <stdio.h> int main(void) { int i, j, k, a[3][4], b[4][5], c[3][5] = {0}; puts("please input the elements of matrix a.") 阅读全文
posted @ 2021-05-01 12:42 小鲨鱼2018 阅读(246) 评论(0) 推荐(0) 编辑