• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell
您的位置:首页 > 脚本语言 >python > Python中join和split用法实例

Python中join和split用法实例

作者:junjie 字体:[增加 减小] 来源:互联网

junjie 通过本文主要向大家介绍了python split join,split join 的区别,split reverse join,split join,js split join等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com

join用来连接字符串,split恰好相反,拆分字符串的。
不用多解释,看完代码,其意自现了。
>>>li = ['my','name','is','bob']
>>>' '.join(li)
'my name is bob'
>>>s = '_'.join(li)
>>>s
'my_name_is_bob'
>>>s.split('_')
['my', 'name', 'is', 'bob']
</div>

其join和split的英文版解释如下:

join(...)
S.join(sequence) -> string

Return a string which is the concatenation of the strings in the
sequence.  The separator between elements is S.

split(...)
S.split([sep [,maxsplit]]) -> list of strings

Return a list of the words in the string S, using sep as the
delimiter string.  If maxsplit is given, at most maxsplit
splits are done. If sep is not specified or is None, any
whitespace string is a separator and empty strings are removed
from the result.

</div>

您可能想查找下面的文章:

  • 深入浅析Python中join 和 split详解(推荐)
  • Python中join和split用法实例

相关文章

  • 利用Python生成文件md5校验值函数的方法
  • python实现批量改文件名称的方法
  • Python实现把xml或xsl转换为html格式
  • Python ORM框架SQLAlchemy学习笔记之安装和简单查询实例
  • python使用win32com在百度空间插入html元素示例
  • Python程序设计入门(4)模块和包
  • Python同时向控制台和文件输出日志logging的方法
  • 理解Python中的With语句
  • python实现批量转换文件编码(批转换编码示例)
  • Python中实现两个字典(dict)合并的方法

文章分类

  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell

最近更新的内容

    • python函数返回多个值的示例方法
    • python实现查找两个字符串中相同字符并输出的方法
    • python 根据pid杀死相应进程的方法
    • Python使用Redis实现作业调度系统(超简单)
    • 使用Python生成随机密码的示例分享
    • python检测远程端口是否打开的方法
    • python里大整数相乘相关技巧指南
    • 用Python中的__slots__缓存资源以节省内存开销的方法
    • 使用python实现拉钩网上的FizzBuzzWhizz问题示例
    • 给Python的Django框架下搭建的BLOG添加RSS功能的教程

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有