- 15
- 0
例如:
class str(object):
"""
str(object='') -> str
str(bytes_or_buffer[, encoding[, errors]]) -> str
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'.
"""
其中一个函数
def capitalize(self): # real signature unknown; restored from __doc__
"""
S.capitalize() -> str
Return a capitalized version of S, i.e. make the first character
have upper case and the rest lower case.
"""
return ""
这个函数到底返回了什么?难道返回了一个空字符吗?
def endswith(self, suffix, start=None, end=None): # real signature unknown; restored from __doc__
"""
S.endswith(suffix[, start[, end]]) -> bool
Return True if S ends with the specified suffix, False otherwise.
With optional start, test S beginning at that position.
With optional end, stop comparing S at that position.
suffix can also be a tuple of strings to try.
"""
return False
这个函数,返回False ,什么意思?
def find(self, sub, start=None, end=None): # real signature unknown; restored from __doc__
"""
S.find(sub[, start[, end]]) -> int
Return the lowest index in S where substring sub is found,
such that sub is contained within S[start:end]. Optional
arguments start and end are interpreted as in slice notation.
Return -1 on failure.
"""
return 0
这个返回一个0 ?
def format(self, *args, **kwargs): # known special case of str.format
"""
S.format(*args, **kwargs) -> str
Return a formatted version of S, using substitutions from args and kwargs.
The substitutions are identified by braces ('{' and '}').
"""
pass
这个是一pass结尾的,那么要这个函数有什么意义
但是我在实际应用他们的时候,返回的并不是这样的?
我现在的以为是:这个类里面的这些函数,函数体里面什么逻辑都没有写?那么函数是怎么运行的?
0
打赏
收藏
点击回答
- 共 0 条
- 全部回答
-
╰静若安然ぴ 普通会员 1楼
在Python中,
pass是一种常用的注释符号,它表示不执行任何操作,而是用于表示程序的空白或默认行为。在函数定义中,pass可以用来简化代码,避免重复的代码块。在Python中,所有的函数定义都应包含
pass。例如:python def my_function(): pass在这个例子中,
pass表示函数my_function的空白,如果函数没有特殊的行为或需要额外的注释,那么可以使用pass来简化代码。需要注意的是,
pass并不是一个内置的Python关键字,而是通过一些工具包(如passlib)提供的。如果你正在使用这些工具包,那么在使用pass时需要检查它们的文档,确保你正在使用正确的语法。此外,
pass也被广泛用于其他场景,例如在处理错误时,表示程序没有错误发生。在try/except块中,如果except块中没有包含pass,那么except块中的代码不会被执行。在这种情况下,可以使用pass来避免代码块中的内容被打印出来。
更多回答
网站公告
- 扫一扫访问手机版
回答动态

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器更新之后。服务器里面有部分玩家要重新创建角色是怎么回事啊?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题函数计算不同地域的是不能用内网吧?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题ARMS可以创建多个应用嘛?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题在ARMS如何申请加入公测呀?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题前端小程序接入这个arms具体是如何接入监控的,这个init方法在哪里进行添加?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器刚到期,是不是就不能再导出存档了呢?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器的游戏版本不兼容 尝试更新怎么解决?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器服务器升级以后 就链接不上了,怎么办?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器转移以后服务器进不去了,怎么解决?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器修改参数后游戏进入不了,是什么情况?预计能赚取 0积分收益
- 回到顶部
- 回到顶部
