创建str对象:

  单引号: 'allows embedded "double" quotes'

  双引号: "allows embedded 'single' quotes"

  三引号: '''Three single quotes''', """Three double quotes"""   #可存储跨行的字符串

    添加"r"前缀,转义字符失去它的转义意义。

  str(object[, encoding, errors]):

    对于普通对象:默认返回"objec.__str__()",若无此方法,则返回"repr(object)"。

    若有encoding和errors参数,则object必须是byte对象或者bytearray对象。

方法:  

  str.capitalize()  -> str

    返回一个首字母大写的字符串拷贝

  str.casefold()  -> str

    返回一个全小写的字符拷贝,可用于忽略大小写的字符匹配。

    类似于str.lower(),但它完全消除字符间的差别

  str.center(width[,fillchar])  -> str

    返回一个居中的长度为width字符串,fillchar可指定前后的填充字符,默认为空格,填充的字符长度只能为1  

  str.count(sub[, start[, end]])  ->

  str.encode(encoding="utf-8", errors="strict")

  str.endswith(suffix[,start[,end]])

  str.expandtabs(tabsize=8)

  str.find(sub[, start[, end]])

  str.format(*args, **kwargs)

  str.format_map(mapping)

  str.index(sub[, start[, end]])

posted on 2016-08-24 20:29  一笙、  阅读(261)  评论(0)    收藏  举报