摘要:
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
阅读(74)
评论(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
阅读(3399)
评论(0)
推荐(0)
摘要:
python中拆分字符串 1、 >>> test1 = "abxcdxefxfh" >>> test1 'abxcdxefxfh' >>> test1.split(sep = "x") ['ab', 'cd', 'ef', 'fh'] 阅读全文
posted @ 2021-05-01 21:51
小鲨鱼2018
阅读(399)
评论(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
阅读(2717)
评论(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
阅读(3795)
评论(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
阅读(2080)
评论(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
阅读(703)
评论(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
阅读(695)
评论(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
阅读(620)
评论(0)
推荐(0)
摘要:
python中enumerate函数。 1、python中enumerate函数 enumerate函数的应用对象为序列(列表、元组、字符串), 返回一个由二元组组成的可迭代对象,二元组由可迭代参数的索引号及其对应的元素组成。 列表 >>> test1 = ["aaa","bbb","ccc"] > 阅读全文
posted @ 2021-05-01 20:37
小鲨鱼2018
阅读(602)
评论(0)
推荐(0)

浙公网安备 33010602011771号