![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
字符串
有点坏。
编写不易,希望各位大神多多指教
展开
-
python 字符串
字符串 字符串替换replace 与translate区别 replace: 从左到右替换指定的元素,可以指定替换的个数,默认全部替换 translate: 按照对应关系来替换内容 from string import maketrans intab = “abcdew” # 需要转换成字符组成的字符串 outtab = “12ej66” # 转换的目标字符组成的字符串 两个字符串的长度必须...原创 2018-12-27 19:57:42 · 238 阅读 · 0 评论 -
python 字符串练习题
1.‘2018-11-12’去掉‘-’输出 s = '2018-11-12' a = s.replace('-', '') print(a) 统计字符串a中 1的个数 a=‘201811’ #第一种: b=a.count('1') print(b) #第二种: count=0 for i in a: if i=='1': count+=1 print(count) 3....原创 2019-01-02 18:12:58 · 1846 阅读 · 0 评论