如何翻译"method"和"function"?它们又有什么区别?

您所在的位置:网站首页 method中文 如何翻译"method"和"function"?它们又有什么区别?

如何翻译"method"和"function"?它们又有什么区别?

#如何翻译"method"和"function"?它们又有什么区别?| 来源: 网络整理| 查看: 265

似乎大家的意思都是:函数和方法只是名称上的不同而已。

下面,我把整段话copy过来,大家讨论讨论:

The Difference Between Methods and Functions

You may be wondering why Python has methods, since they seem to act just like functions. Some data types have methods. Methods are functions associated with values of that data type. For example, string methods are functions that can be called on any string. If you have the string value'Hello', you could call the string method upper() like this: 'Hello'.upper(). Or if the string 'Hello' were stored in a variable namedspam, it would look like this: spam.upper()

 You cannot call string methods on values of other data types. For example, [1, 2, 'apple'].upper() would cause an error because [1, 2, 'apple'] is a list and upper() is a string method.

The values of data types that have methods are also called objects. Object-oriented programming is a bit advanced for this book, and you don't need to understand it to make games. Just understand that objects are another name for a values of data types that have methods. For example, all strings and lists are objects.

这是原文的地址:http://inventwithpython.com/chapter9.html



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3