#!/usr/bin/python # -*- coding: utf-8 -*- #Author: zhaosj ###字符串方法 ###1.split()切割### # a = 'www.baidu.com' # print(a.split('.'))#以'.'进行切割字符串 # #结果:['www', 'baidu', 'com'] ###2.repalce()替换### # b = 'This is apples' # c = b.replace('is', 'a')#使用a替换is # print (c) # #结果:Tha a apples ###3.strip()删除### # a = ' python is cool ' # print (a.strip())#删除两次空格 # #结果:python is cool ###4.format()字符串格式化### # a = '{} is my love'.format('Python') # print(a)#将Python字符串放到花括号中 # #结果:Python is my love
Python字符串方法
最新推荐文章于 2023-01-05 15:34:13 发布