strip()

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:将时间格式转化为字符船格式

猜你喜欢

转载自www.cnblogs.com/leolaosao/p/9038274.html