python 空格替换
来源:互联网 发布:什么是淘宝旺旺号啊 编辑:程序博客网 时间:2024/05/22 03:04
python 空格替换
方法一:
#-*-coding:utf-8-*-class Handle(): def replaceSpace(self,string): if string == None:return None if len(string) == 0:return 0 return string.replace(' ','*')
方法二
#线性复杂度#-*-coding:utf-8-*-class Handle(): def replaceSpace(self,string): if string == None:return None if len(string) == 0:return 0 result = '' for s in string: if s.isspace(): result = result+'*' else: result = result+s return result
#测试用例strhandle = Handle()string_list = ['',None,'This is a string for test !']for string in string_list: string = strhandle.replaceSpace(string) print string#结果:>>> 0NoneThis*is*a*string*for*test*!
阅读全文
0 0
- python 刷题:替换空格
- 编程:空格替换Python
- Python :替换空格
- 4替换空格python
- python 空格替换
- python处理文件tab替换成空格
- 剑指offer 算法2 替换空格(python)
- 剑指offer之空格替换(Python)
- 空格替换
- 替换空格
- 空格替换
- 替换空格
- 替换空格
- 替换空格
- 替换空格
- 替换空格
- 替换空格
- 替换空格
- SpringMVC 下载Excel模板和导入数据
- mac下 adb :command not found问题解决
- 8皇后问题
- thinkphp5.0学习(七):数据库操作
- Vue 自定义指令
- python 空格替换
- 回文链表
- hadoop 8088端口网页无法打开的原因分析
- Java后端程序员1年工作经验总结
- windows7环境下Eclipse集成Python开发环境+安装TensorFlow
- dexcachelist导致anr
- 八皇后
- 排序算法之快速排序
- Android开发---手机号码输入框(满11位自动跳到下个输入框)