python-str类官方文档翻译

本文为help(str)文档的翻译,如有错误,可留言。Help on class str in module builtins:class str(object)| str(object=’’) -> str| # 将object转换为str,若参数为空则返回空串| str(bytes_or_buffer[, encoding[, errors]]) -> str| ...
摘要由CSDN通过智能技术生成

本文为help(str)文档的翻译,如有错误,可留言。

Help on class str in module builtins:

class str(object)
| str(object=’’) -> str
| # 将object转换为str,若参数为空则返回空串
| str(bytes_or_buffer[, encoding[, errors]]) -> str
| # 如果没有给出encoding和errors,则返回object.str()或repr(object)方法的返回对象。
| # 否则:第一个参数应该是一个能被给出的编码方式正确编码,且能进行错误处理的的数据缓冲器对象
| # 如果第一个参数是类似于bytes对象,则该方法相当于 bytes.decode(encoding, errors)。
| # 如果第一个参数不是bytes类对象,会先获取缓冲区下层的bytes类对象。
| # 详情请参见二进制序列类-bytes、bytearray和memoryview,或通过“缓冲协议”了解缓冲区对象的信息
| # encoding默认为sys.getdefaultencoding()方法返回的编码方式(即当前系统所用的编码方式)
| # errors默认为strict
|
| Create a new string object from the given object. If encoding or
| errors is specified, then the object must expose a data buffer
| that will be decoded using the given encoding and error handler.
| Otherwise, returns the result of object.str() (if defined)
| or repr(object).
| encoding defaults to sys.getdefaultencoding().
| errors defaults to ‘strict’.
|
| Methods defined here:
|
| add(self, value, /)
| Return self+value.
|
| contains(self, key, /)
| Return key in self.
|
| eq(self, value, /)
| Return self==value.
|
| format(self, format_spec, /)
| Return a formatted version of the string as described by format_spec.
|
| ge(self, value, /)
| Return self>=value.
|
| getattribute(self, name, /)
| Return getattr(self, name).
|
| getitem(self, key, /)
| Return self[key].
|
| getnewargs(…)
|
| gt(self, value, /)
| Return self>value.
|
| hash(self, /)
| Return hash(self).
|
| iter(self, /)
| Implement iter(self).
|
| le(self, value, /)
| Return self<=value.
|
| len(self, /)
| Return len(self).
|
| lt(self, value, /)
| Return self<value.
|
| mod(self, value, /)
| Return self%value.
|
| mul(self, value, /)
| Return selfvalue.
|
| ne(self, value, /)
| Return self!=value.
|
| repr(self, /)
| Return repr(self).
|
| rmod(self, value, /)
| Return value%self.
|
| rmul(self, value, /)
| Return value
self.
|
| sizeof(self, /)
| Return the size of the string in memory, in bytes.
|
| str(self, /)
| Return str(self).
|
| capitalize(self, /)
| Return a capitalized version of the string.
| More specifically, make the first character have upper case and the rest lower
| case.
| # 返回将字符串首字母转换为大写,其他字母都转换为小写的版本
|
| casefold(self, /)
| Return a version of the string suitable for caseless comparisons.
| # 返回字符串消除大小写的版本,用于忽略大小写进行比较的场合。其与lower()有区别
| # 消除大小写的详细描述课参考unicode标准的3.13节
|
| center(self, width, fillchar=’ ‘, /)
| Return a centered string of length width.
| Padding is done using the specified fill character (default is a space).
| # 返回宽度的width的字符串,原字符串居中,两端以fillchar填充。
|
| count(…)
| S.count(sub[, start[, end]]) -> int
| Return the number of non-overlapping occurrences of s

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值