1、使用字符串函数replace

>>> a = 'hello world'

>>> a.replace(' ', '')
'helloworld'

看上这种方法真的是很笨。

2、使用字符串函数split

>>> a = ''.join(a.split())

>>> print(a)
helloworld

3、使用正则表达式

>>> import re
>>> strinfo = re.compile() >>> strinfo = re.compile(' ') >>> b = strinfo.sub('', a)
>>> print(b)
helloworld

最新文章

  1. JAVA EE Hibernate基础一之环境配置
  2. c#设计模式之简单工厂
  3. springmvc中RequestMapping的解析
  4. 在SQL Server 2012中实现CDC for Oracle
  5. Delphi 的字符及字符串[5] - 字符串与 Windows API
  6. Druid:一个用于大数据实时处理的开源分布式系统
  7. 免费web直接打印的控件PAZU
  8. Datatable转换成List实体对象列表 几个实例
  9. IE,火狐,谷歌浏览器下js判断滚动条是否已拉到页面最底部
  10. poj 1011 Sticks (DFS+剪枝)
  11. 提高duilib的richedit控制的一些特征
  12. Hadoop学习之配置Eclipse远程调试Hadoop
  13. 16个必须熟悉的linux服务器监控命令
  14. 从构建分布式秒杀系统聊聊WebSocket推送通知
  15. TensorFlow走过的坑之---数据读取和tf中batch的使用方法
  16. (27)session(设置值、取值、修改、删除)
  17. windows.onload和body的onload属性的区别
  18. php导出excel不知道列数 php26进制函数
  19. Event Tracing For Windows
  20. CasperJS API中文博客链接

热门文章

  1. angular - 如何运行在起来 - 使用nginx
  2. Joomla详细安装图文教程
  3. Hadoop之词频统计小实验
  4. android logo设计
  5. Mac和Windows上Android Studio经常使用的快捷键
  6. core image几个滤镜样例 oc版本号和swift版本号
  7. nginx正则说明
  8. vimrc之fileformat
  9. Vue 组件6内联模板
  10. IDEA 2017破解 license server激活