Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python 中没有avg函数,这个里的avg函数是从何而来 #346

Open
Zhao-x-u opened this issue Apr 23, 2021 · 2 comments
Open

python 中没有avg函数,这个里的avg函数是从何而来 #346

Zhao-x-u opened this issue Apr 23, 2021 · 2 comments

Comments

@Zhao-x-u
Copy link

def drop_first_last(grades):
first, *middle, last = grades
return avg(middle)

avg这个函数是那个模块中的呢?我在使用的时候找不到

@Jiuh-star
Copy link
Contributor

avg()不存在与Python内置库中,它应该是作者自己实现的一个函数,但我想没有这个函数的具体实现应该也不会很难看出这个函数的目的。
但如果你需要avg(),请访问作者的代码示例仓库 https://github.com/dabeaz/python-cookbook/blob/6e46b78e5644b3e5bf7426d900e2203b7cc630da/src/7/functions_that_accept_any_number_of_arguments/example.py

@yusancky
Copy link

作者在7.1节定义了avg函数

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants