python字符串方法分类

 时间:2024-10-13 13:56:44

1、打开sublime text 3编辑器,新建一个PY文件。

python字符串方法分类

2、test = "hey"挢旗扦渌;test_new = test.center(10, "$")print(test_new)填充类的有center()这个方法,可以指定字符,然后往两边填充,第一个参数是总的字符串长度。

python字符串方法分类

3、test = " hey "test_new = test.strip()删减类的经常用来去除一些不必要的字符,比如空格,strip()可以去除两头的。

python字符串方法分类

4、test = "hey"test_new = test.upper()变形类的有upper(),也就是把英语的字符都变为大写。当然也有小写等功能。

python字符串方法分类

5、test = "hey you where are you"test_new = test.split()分切类最常见的就是split(),也就是把字符串变为列表。

python字符串方法分类

6、test = "hey you 嘛术铹砾where are you"test_new = test.replace("you", "U")替代类的用replace()可以一下子替换字符内容。

python字符串方法分类

7、test = "hey you where are you"test_new = test.find("where")查找类的,可以快速定位到字符的第一个序号。

python字符串方法分类
  • python3.6下的gpu版本tensorflow安装详细指南
  • C#如何使用DataSet控件
  • pycharm怎么上传外部更改设置
  • datagridview中按钮不显示文本怎么办?
  • 如何使用python语言中的方法拼接不同列表并展示
  • 热门搜索
    关于宪法的手抄报 讲普通话写规范字手抄报 致敬抗疫英雄手抄报 小学生植树节手抄报 有关春天的手抄报 劳动手抄报简单漂亮 秋天的手抄报 核心价值观手抄报 开学第一课手抄报小学 我的理想手抄报