码迷,mamicode.com
首页 > 其他好文 > 详细

strip()

时间:2018-05-14 22:07:47      阅读:257      评论:0      收藏:0      [点我收藏+]

标签:font   次数   分隔符   date   UI   -o   制表符   live   指定   

1.http://www.runoob.com/python3/python3-string-strip.html

用于去出字符串末尾指定的字符(默认为空格)。

string.lstrip()   在string的左边删除string

 string.rstrip()   在string的右边删除string

2.

python去除字符串中间空格的方法

使用字符串函数split

   a = ‘‘.join(a.split())
   print(a)
   helloworld
  str.split(str="", num=string.count(str)).(分割字符串)
   str -- 分隔符,默认为所有的空字符,包括空格、换行(\n)、制表符(\t)等。
   num -- 分割次数。

  datetime.strptime:将字符串转换为时间格式

  detetime.strftime:将时间格式转化为字符船格式

strip()

标签:font   次数   分隔符   date   UI   -o   制表符   live   指定   

原文地址:https://www.cnblogs.com/leolaosao/p/9038274.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!