From 27c78c9dfc1f9fa80208a1a340ee5504632fe4f2 Mon Sep 17 00:00:00 2001 From: zd6 <35508409+zd6@users.noreply.github.com> Date: Fri, 21 Dec 2018 15:17:45 -0600 Subject: [PATCH] Translation optimized index.md (#21140) improved translation in function description. translated example description. --- guide/chinese/python/max-function/index.md | 28 +++++++++++----------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/guide/chinese/python/max-function/index.md b/guide/chinese/python/max-function/index.md index 731651ed15..f02759976a 100644 --- a/guide/chinese/python/max-function/index.md +++ b/guide/chinese/python/max-function/index.md @@ -2,7 +2,7 @@ title: Python Max Function localeTitle: Python Max函数 --- -`max()`是Python 3中的内置函数。它返回可迭代中的最大项或两个或多个参数中的最大项。 +`max()`是Python 3中的内置函数。它返回可迭代(iterable)中的最大项,它也可以返回两个或多个参数中的最大项。 ## 参数 @@ -17,35 +17,35 @@ max(2, 3) 参数无效: ``` -max(2, 'a') - max([1, 2, 3, 'a']) - max([]) +max(2, 'a') #参数类型一致 + max([1, 2, 3, 'a']) #迭代中有参数不一致 + max([]) #空的迭代 ``` -## 回报价值 +## 返回值 返回iterable中的最大项。如果提供了两个或多个位置参数,则返回最大的位置参数。如果iterable为空并且未提供default,则引发`ValueError` 。 ## 代码示例 ``` -print(max(2, 3)) # Returns 3 as 3 is the largest of the two values - print(max(2, 3, 23)) # Returns 23 as 23 is the largest of all the values +print(max(2, 3)) # 返回两个参数中的最大值 3 。 + print(max(2, 3, 23)) # 返回三个参数中的最大值 23 。 list1 = [1, 2, 4, 5, 54] - print(max(list1)) # Returns 54 as 54 is the largest value in the list + print(max(list1)) # 返回 list1 (一个迭代变量)中的最大值 54 。 list2 = ['a', 'b', 'c' ] - print(max(list2)) # Returns 'c' as 'c' is the largest in the list because c has ascii value larger then 'a' ,'b'. - + print(max(list2)) # 返回’c',因为‘c'是 list2 中ascii值最大的, ‘a'的ascii值是97,'b'的ascii值是98,而'c'的ascii值是99。 + list3 = [1, 2, 'abc', 'xyz'] - print(max(list3)) # Gives TypeError as values in the list are of different type + print(max(list3)) # 返回 TypeError, 因为 list3 中的变量类型并不一致。 - #Fix the TypeError mentioned above first before moving on to next step + #请先将此错误修改再进行后面的编码 list4 = [] - print(max(list4)) # Gives ValueError as the argument is empty + print(max(list4)) # 返回 ValueError, 因为 list4 是空的。 ``` ![:rocket:](//forum.freecodecamp.com/images/emoji/emoji_one/rocket.png?v=2 ":火箭:") [运行代码](https://repl.it/CVok) -[官方文件](https://docs.python.org/3/library/functions.html#max) \ No newline at end of file +[官方文件](https://docs.python.org/3/library/functions.html#max)