基本数据类型简单整理

captlze首字母大写
upper()全大写
lower()全小写
find通过元素找索引,找不到-1
index()通过元素找索引,找不到 报错
swpcase 大小写翻转

repalce(old,new,count)替换
isdigit() 返回bool值
isapha()
isnumpha()
startswith endswith
title 首字母大写
center()居中
strip()lstrip rstrip

#!/usr/bin/python
# -*- coding: UTF-8 -*-
str = "00000003210Runoob01230000000";
print str.strip( '0' ); # 去除首尾字符 0
str2 = " Runoob "; # 去除首尾空格
print str2.strip();

 


split 分割
format 格式化输出
{}
{0}{1}{2}{0}
{name}{age}{hobby} name= age+ hobby


len() 长度
count 计数

for i in 可迭代对象:
pass

posted @ 2018-10-22 16:25  最末  阅读(80)  评论(0)    收藏  举报