Python学习笔记(一):list属性及方法浅析
来源:互联网 发布:粤语网络词 编辑:程序博客网 时间:2024/06/05 00:22
列表学习。
List是python中的基本数据结构之一。创建一个列表的方法
L = [1,2,3,'a']
通过help(list)查看列表的属性及方法。
>>> help(list)
Help on class list in module builtins:
class list(object)
| list() -> new empty list
| list(iterable) -> new list initialized from iterable's items
|
| Methods defined here:
|
| __add__(self, value, /)
| Return self+value.
|
| __contains__(self, key, /)
| Return key in self.
|
| __delitem__(self, key, /)
| Delete self[key].
|
| __eq__(self, value, /)
| Return self==value.
|
| __ge__(self, value, /)
| Return self>=value.
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __getitem__(...)
| x.__getitem__(y) <==> x[y]
|
| __gt__(self, value, /)
| Return self>value.
|
| __iadd__(self, value, /)
| Implement self+=value.
|
| __imul__(self, value, /)
| Implement self*=value.
|
| __init__(self, /, *args, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| __iter__(self, /)
| Implement iter(self).
|
| __le__(self, value, /)
| Return self<=value.
|
| __len__(self, /)
| Return len(self).
|
| __lt__(self, value, /)
| Return self<value.
|
| __mul__(self, value, /)
| Return self*value.n
|
| __ne__(self, value, /)
| Return self!=value.
|
| __new__(*args, **kwargs) from builtins.type
| Create and return a new object. See help(type) for accurate signature.
|
| __repr__(self, /)
| Return repr(self).
|
| __reversed__(...)
| L.__reversed__() -- return a reverse iterator over the list
|
| __rmul__(self, value, /)
| Return self*value.
|
| __setitem__(self, key, value, /)
| Set self[key] to value.
|
| __sizeof__(...)
| L.__sizeof__() -- size of L in memory, in bytes
|
| append(...)
| L.append(object) -> None -- append object to end
|
| clear(...)
| L.clear() -> None -- remove all items from L
|
| copy(...)
| L.copy() -> list -- a shallow copy of L
|
| count(...)
| L.count(value) -> integer -- return number of occurrences of value
|
| extend(...)
| L.extend(iterable) -> None -- extend list by appending elements from the iterable
|
| index(...)
| L.index(value, [start, [stop]]) -> integer -- return first index of value.
| Raises ValueError if the value is not present.
|
| insert(...)
| L.insert(index, object) -- insert object before index
|
| pop(...)
| L.pop([index]) -> item -- remove and return item at index (default last).
| Raises IndexError if list is empty or index is out of range.
|
| remove(...)
| L.remove(value) -> None -- remove first occurrence of value.
| Raises ValueError if the value is not present.
|
| reverse(...)
| L.reverse() -- reverse *IN PLACE*
|
| sort(...)
| L.sort(key=None, reverse=False) -> None -- stable sort *IN PLACE*
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __hash__ = None
下面分别来解析:
list() -> new empty list 新建一个空的列表
list(iterable) -> new list initialized from iterable's items
将可迭代的items转换为列表,例如字符串和元组
__add__(self, value, /) Return self+value.列表相加
__contains__(self, key, /) Return key in self. 判断列表是否包含某对象
__delitem__(self, key, /) Delete self[key]. 删除某对象
__eq__(self, value, /) Return self==value. 判断列表是否等于某列表
__ge__(self, value, /) Return self>=value.判断列表是否不小于某列表。与__eq__类似
__getattribute__(self, name, /) Return getattr(self, name).
__getitem__(...) x.__getitem__(y) <==> x[y] #返回某索引下的对象
__gt__(self, value, /) Return self>value. 判断列表是否大于某列表。与__eq__类似
__iadd__(self, value, /) Implement self+=value. self+=value value可以是任何可迭代对象。
__imul__(self, value, /) Implement self*=value. self*=value value必须是integer类型
__init__(self, /, *args, **kwargs) Initialize self. See help(type(self)) for accurate signature. 列表初始化
__iter__(self, /) Implement iter(self).
__len__(self, /) Return len(self). 返回列表长度,即元素个数
__lt__(self, value, /) Return self<value. 判断列表是小于某列表。与__eq__类似
__mul__(self, value, /) Return self*value.n 与__imul__类似,但本身不会改变
__ne__(self, value, /) Return self!=value.判断列表是不等于某列表。与__eq__类似
__new__(*args, **kwargs) from builtins.type
Create and return a new object. See help(type) for accurate signature. 创建一个新的列表对象。
__repr__(self, /) Return repr(self). 相当于repr函数
__reversed__(...) L.__reversed__() -- return a reverse iterator over the list 返回列表的逆序迭代器,列表本身不会改变
__rmul__(self, value, /) Return self*value. 不知道与__mul__ 有啥区别。
__setitem__(self, key, value, /) Set self[key] to value. 改变列表某位置的对象。
__sizeof__(...) L.__sizeof__() -- size of L in memory, in bytes 返回列表所占内存
append(...) L.append(object) -> None -- append object to end 添加对象到列表末尾
clear(...) L.clear() -> None -- remove all items from L 清空列表
copy(...) L.copy() -> list -- a shallow copy of L 列表浅拷贝
count(...) L.count(value) -> integer -- return number of occurrences of value 返回列表中某对象的个数。
extend(...) L.extend(iterable) -> None -- extend list by appending elements from the iterable 将迭代器对象转换为列表并添加到列表末端。
index(...)
| L.index(value, [start, [stop]]) -> integer -- return first index of value.
| Raises ValueError if the value is not present.
insert(...)
| L.insert(index, object) -- insert object before index 在index位置插入任何对象
pop(...)
| L.pop([index]) -> item -- remove and return item at index (default last).
| Raises IndexError if list is empty or index is out of range.
删除index位置处的对象并返回该对象,列表本身改变
remove(...)
| L.remove(value) -> None -- remove first occurrence of value.
| Raises ValueError if the value is not present.
删除某个第一次出现的值,返回None
reverse(...)
| L.reverse() -- reverse *IN PLACE* 列表逆序
sort(...) 对列表进行排序,列表元素必须是同一类型
| L.sort(key=None, reverse=False) -> None -- stable sort *IN PLACE*
List是python中的基本数据结构之一。创建一个列表的方法
L = [1,2,3,'a']
通过help(list)查看列表的属性及方法。
>>> help(list)
Help on class list in module builtins:
class list(object)
| list() -> new empty list
| list(iterable) -> new list initialized from iterable's items
|
| Methods defined here:
|
| __add__(self, value, /)
| Return self+value.
|
| __contains__(self, key, /)
| Return key in self.
|
| __delitem__(self, key, /)
| Delete self[key].
|
| __eq__(self, value, /)
| Return self==value.
|
| __ge__(self, value, /)
| Return self>=value.
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __getitem__(...)
| x.__getitem__(y) <==> x[y]
|
| __gt__(self, value, /)
| Return self>value.
|
| __iadd__(self, value, /)
| Implement self+=value.
|
| __imul__(self, value, /)
| Implement self*=value.
|
| __init__(self, /, *args, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| __iter__(self, /)
| Implement iter(self).
|
| __le__(self, value, /)
| Return self<=value.
|
| __len__(self, /)
| Return len(self).
|
| __lt__(self, value, /)
| Return self<value.
|
| __mul__(self, value, /)
| Return self*value.n
|
| __ne__(self, value, /)
| Return self!=value.
|
| __new__(*args, **kwargs) from builtins.type
| Create and return a new object. See help(type) for accurate signature.
|
| __repr__(self, /)
| Return repr(self).
|
| __reversed__(...)
| L.__reversed__() -- return a reverse iterator over the list
|
| __rmul__(self, value, /)
| Return self*value.
|
| __setitem__(self, key, value, /)
| Set self[key] to value.
|
| __sizeof__(...)
| L.__sizeof__() -- size of L in memory, in bytes
|
| append(...)
| L.append(object) -> None -- append object to end
|
| clear(...)
| L.clear() -> None -- remove all items from L
|
| copy(...)
| L.copy() -> list -- a shallow copy of L
|
| count(...)
| L.count(value) -> integer -- return number of occurrences of value
|
| extend(...)
| L.extend(iterable) -> None -- extend list by appending elements from the iterable
|
| index(...)
| L.index(value, [start, [stop]]) -> integer -- return first index of value.
| Raises ValueError if the value is not present.
|
| insert(...)
| L.insert(index, object) -- insert object before index
|
| pop(...)
| L.pop([index]) -> item -- remove and return item at index (default last).
| Raises IndexError if list is empty or index is out of range.
|
| remove(...)
| L.remove(value) -> None -- remove first occurrence of value.
| Raises ValueError if the value is not present.
|
| reverse(...)
| L.reverse() -- reverse *IN PLACE*
|
| sort(...)
| L.sort(key=None, reverse=False) -> None -- stable sort *IN PLACE*
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __hash__ = None
下面分别来解析:
list() -> new empty list 新建一个空的列表
In [1]: a = list()In [2]: aOut[2]: []
list(iterable) -> new list initialized from iterable's items
将可迭代的items转换为列表,例如字符串和元组
In [6]: s = "hello world!"In [7]: L = list(s)In [8]: LOut[8]: ['h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd', '!']
__add__(self, value, /) Return self+value.列表相加
In [1]: a = [1,2]In [2]: b = [1,2]In [3]: a.__add__(b) # 返回a+b,a,b本身没有改变Out[3]: [1, 2, 1, 2]In [4]: aOut[4]: [1, 2] In [5]: bOut[5]: [1, 2]In [6]: c = a.__add__(b)In [7]: cOut[7]: [1, 2, 1, 2]In [8]: d = a+bIn [9]: c == bOut[9]: FalseIn [10]: c == dOut[10]: True
__contains__(self, key, /) Return key in self. 判断列表是否包含某对象
In [11]: L = [1,2,3,4]In [12]: L.__contains__(1)Out[12]: TrueIn [13]: L.__contains__(2)Out[13]: TrueIn [14]: L.__contains__(0)Out[14]: FalseIn [15]: L.__contains__('a')Out[15]: FalseIn [16]: L.__contains__(L) #并不包含本身Out[16]: FalseIn [18]: L in LOut[18]: FalseIn [19]: 2 in LOut[19]: TrueIn [20]: 0 in LOut[20]: False
__delitem__(self, key, /) Delete self[key]. 删除某对象
In [21]: L = [1,2,3]In [22]: L.__delitem__(0) #删除第0个对象In [23]: LOut[23]: [2, 3] In [24]: del L[1] #删除第1个对象In [25]: LOut[25]: [2]
__eq__(self, value, /) Return self==value. 判断列表是否等于某列表
In [36]: a = [1,2,3,4]In [37]: b = [1,2]In [38]: a.__eq__(1)Out[38]: NotImplemented #没有实现该功能In [39]: a.__eq__([1,2])Out[39]: FalseIn [40]: a.__eq__(b)Out[40]: FalseIn [41]: a.__eq__([1,2,3,4])Out[41]: TrueIn [42]: a.__eq__((1,2,3,4))Out[42]: NotImplemented与 == 略有差异In [43]: a = [1,2,3,4]In [44]: b = [1,2]In [45]: a == 1Out[45]: FalseIn [46]: a == [1,2]Out[46]: FalseIn [47]: a == [1,2,3,4]Out[47]: TrueIn [48]: a == bOut[48]: FalseIn [49]: a == (1,2,3,4)Out[49]: False
__ge__(self, value, /) Return self>=value.判断列表是否不小于某列表。与__eq__类似
__getattribute__(self, name, /) Return getattr(self, name).
In [63]: a = [1,2,3,4]In [64]: a.__getattribute__('__len__')Out[64]: <method-wrapper '__len__' of list object at 0x02558EE0>In [65]: b = a.__getattribute__('__len__')In [66]: b()Out[66]: 4In [67]: aOut[67]: [1, 2, 3, 4]In [68]: a.__getattribute__('copy')Out[68]: <function list.copy>In [69]: b = a.__getattribute__('copy')In [70]: c = b()In [71]: cOut[71]: [1, 2, 3, 4]
__getitem__(...) x.__getitem__(y) <==> x[y] #返回某索引下的对象
In [1]: a = [1,2,3,"hello",(1,2,3)]In [2]: a.__getitem__(0)Out[2]: 1In [3]: a.__getitem__(3)Out[3]: 'hello'In [4]: a.__getitem__(4)Out[4]: (1, 2, 3)In [5]: a.__getitem__(5) 无法访问越界的对象---------------------------------------------------------------------------IndexError Traceback (most recent call last)<ipython-input-5-3a58e3eacf6a> in <module>()----> 1 a.__getitem__(5)IndexError: list index out of range #越界报错In [6]: a = [1,2,3,"hello",(1,2,3)]In [7]: a[0]Out[7]: 1In [8]: a[3]Out[8]: 'hello'In [9]: a[4]Out[9]: (1, 2, 3)In [10]: a[5]---------------------------------------------------------------------------IndexError Traceback (most recent call last)<ipython-input-10-b6a934feab86> in <module>()----> 1 a[5]IndexError: list index out of range
__gt__(self, value, /) Return self>value. 判断列表是否大于某列表。与__eq__类似
__iadd__(self, value, /) Implement self+=value. self+=value value可以是任何可迭代对象。
In [3]: a = [1,2,3,4]In [4]: a.__iadd__("hello") Out[4]: [1, 2, 3, 4, 'h', 'e', 'l', 'l', 'o'] #先将字符串转换为列表,然后再相加,列表会改变In [5]: a.__iadd__((1,2,3))Out[5]: [1, 2, 3, 4, 'h', 'e', 'l', 'l', 'o', 1, 2, 3] #先将元组转换为列表,然后再相加,列表会改变In [6]: a.__iadd__([1111,1113]) #列表相加,列表会改变Out[6]: [1, 2, 3, 4, 'h', 'e', 'l', 'l', 'o', 1, 2, 3, 1111, 1113]In [7]: a #a已改变Out[7]: [1, 2, 3, 4, 'h', 'e', 'l', 'l', 'o', 1, 2, 3, 1111, 1113]
__imul__(self, value, /) Implement self*=value. self*=value value必须是integer类型
In [15]: a = [1,2,3,'abc']In [16]: a.__imul__(2) #*2并返回给aOut[16]: [1, 2, 3, 'abc', 1, 2, 3, 'abc']In [17]: a #a已改变Out[17]: [1, 2, 3, 'abc', 1, 2, 3, 'abc']In [18]: a.__imul__([1,2]) #参数不是integer类型,报错---------------------------------------------------------------------------TypeError Traceback (most recent call last)<ipython-input-18-58ca78754a99> in <module>()----> 1 a.__imul__([1,2])TypeError: 'list' object cannot be interpreted as an integer
__init__(self, /, *args, **kwargs) Initialize self. See help(type(self)) for accurate signature. 列表初始化
In [23]: a = []In [24]: b = [1,2,3,4]In [25]: a.__init__(b)In [26]: aOut[26]: [1, 2, 3, 4]In [27]: a.__init__((1,2,3)) #先将元组转换为列表,再初始化给aIn [28]: aOut[28]: [1, 2, 3]
__iter__(self, /) Implement iter(self).
In [34]: a = [1,2,3,4,54]In [35]: for i in a.__iter__(): ...: print (i) ...:123454In [36]: a.__iter__Out[36]: <method-wrapper '__iter__' of list object at 0x024B7D00>In [37]: a.__iter__() #列表类型的迭代器Out[37]: <list_iterator at 0x25586b0>
__le__(self, value, /) Return self<=value. 判断列表是不大于某列表。与__eq__类似
__len__(self, /) Return len(self). 返回列表长度,即元素个数
In [38]: a = [1,2,3,"abc",(111,222,333)]In [39]: a.__len__()Out[39]: 5In [40]: a.__len__Out[40]: <method-wrapper '__len__' of list object at 0x024C44B8>
__lt__(self, value, /) Return self<value. 判断列表是小于某列表。与__eq__类似
__mul__(self, value, /) Return self*value.n 与__imul__类似,但本身不会改变
In [41]: a = [1,2,3,"abc",(111,222,333)]In [42]: a.__mul__(2)Out[42]: [1, 2, 3, 'abc', (111, 222, 333), 1, 2, 3, 'abc', (111, 222, 333)]In [43]: aOut[43]: [1, 2, 3, 'abc', (111, 222, 333)]
__ne__(self, value, /) Return self!=value.判断列表是不等于某列表。与__eq__类似
__new__(*args, **kwargs) from builtins.type
Create and return a new object. See help(type) for accurate signature. 创建一个新的列表对象。
In [1]: a = [1,2,3,4]In [2]: b = a.__new__(list)In [3]: bOut[3]: []In [4]: b = a.__new__(str)---------------------------------------------------------------------------TypeError Traceback (most recent call last)<ipython-input-4-6fee1f0c3d80> in <module>()----> 1 b = a.__new__(str)TypeError: list.__new__(str): str is not a subtype of listIn [5]: b = a.__new__(tuple)---------------------------------------------------------------------------TypeError Traceback (most recent call last)<ipython-input-5-18991a398a58> in <module>()----> 1 b = a.__new__(tuple)TypeError: list.__new__(tuple): tuple is not a subtype of list
__repr__(self, /) Return repr(self). 相当于repr函数
In [12]: a = [1,2,3,4]In [13]: b = a.__repr__()In [14]: bOut[14]: '[1, 2, 3, 4]' #字符串In [15]: aOut[15]: [1, 2, 3, 4]
__reversed__(...) L.__reversed__() -- return a reverse iterator over the list 返回列表的逆序迭代器,列表本身不会改变
In [19]: a = [1,2,3,4]In [20]: a.__reversed__()Out[20]: <list_reverseiterator at 0x2538c50>In [21]: aOut[21]: [1, 2, 3, 4]In [22]: b = a.__reversed__()In [23]: for i in b: ...: print (i) ...:4321
__rmul__(self, value, /) Return self*value. 不知道与__mul__ 有啥区别。
In [34]: a = [1,2,3,4,"abc"]In [35]: a.__mul__(-1)Out[35]: []In [36]: a.__mul__(0)Out[36]: []In [37]: aOut[37]: [1, 2, 3, 4, 'abc']In [38]: a.__mul__(2)Out[38]: [1, 2, 3, 4, 'abc', 1, 2, 3, 4, 'abc']
__setitem__(self, key, value, /) Set self[key] to value. 改变列表某位置的对象。
In [39]: aOut[39]: [1, 2, 3, 4, 'abc']In [40]: a.__setitem__(2,"aaa")In [41]: aOut[41]: [1, 2, 'aaa', 4, 'abc']In [43]: aOut[43]: [1, 2, 3, 4, 'abc']
__sizeof__(...) L.__sizeof__() -- size of L in memory, in bytes 返回列表所占内存
In [44]: a = []In [45]: a.__sizeof__Out[45]: <function list.__sizeof__>In [46]: a.__sizeof__()Out[46]: 20In [47]: a = [1]In [48]: a.__sizeof__()Out[48]: 24In [49]: a = [1,2,3]In [50]: a.__sizeof__()Out[50]: 32In [51]: a = ['a']In [52]: a.__sizeof__()Out[52]: 24In [53]: a = ['abc']In [54]: a.__sizeof__()Out[54]: 24
append(...) L.append(object) -> None -- append object to end 添加对象到列表末尾
In [55]: a = [1]In [56]: a.append(2)In [57]: aOut[57]: [1, 2]In [58]: a.append('2')In [59]: aOut[59]: [1, 2, '2']In [60]: a.append([1,2])In [61]: aOut[61]: [1, 2, '2', [1, 2]]In [62]: a.append((3,4))In [63]: aOut[63]: [1, 2, '2', [1, 2], (3, 4)]
clear(...) L.clear() -> None -- remove all items from L 清空列表
In [64]: aOut[64]: [1, 2, '2', [1, 2], (3, 4)]In [65]: a.clear()In [66]: aOut[66]: []
copy(...) L.copy() -> list -- a shallow copy of L 列表浅拷贝
In [67]: a = [1,2,3,4]In [68]: b = a.copy()In [69]: aOut[69]: [1, 2, 3, 4]In [70]: bOut[70]: [1, 2, 3, 4]
count(...) L.count(value) -> integer -- return number of occurrences of value 返回列表中某对象的个数。
In [71]: a = [1,2,3,'a','aa',[1,2]]In [72]: a.count(1)Out[72]: 1In [73]: a.count('a')Out[73]: 1In [74]: a.count([1,2])Out[74]: 1In [75]: a.count(0)Out[75]: 0
extend(...) L.extend(iterable) -> None -- extend list by appending elements from the iterable 将迭代器对象转换为列表并添加到列表末端。
In [80]: a = [1,2,3]In [81]: a.extend((1,2,3))In [82]: aOut[82]: [1, 2, 3, 1, 2, 3]In [83]: a.extend([4,5,6])In [84]: aOut[84]: [1, 2, 3, 1, 2, 3, 4, 5, 6]
index(...)
| L.index(value, [start, [stop]]) -> integer -- return first index of value.
| Raises ValueError if the value is not present.
In [85]: aOut[85]: [1, 2, 3, 1, 2, 3, 4, 5, 6]In [86]: a.index(2)Out[86]: 1 #返回第一个出现对象的位置In [87]: a.index(7) #列表中不存在是时报错---------------------------------------------------------------------------ValueError Traceback (most recent call last)<ipython-input-87-e64802c95647> in <module>()----> 1 a.index(7)ValueError: 7 is not in list
insert(...)
| L.insert(index, object) -- insert object before index 在index位置插入任何对象
In [90]: a.insert(0,"abc")In [91]: aOut[91]: ['abc', 1, 2, 3, 1, 2, 3, 4, 5, 6]
pop(...)
| L.pop([index]) -> item -- remove and return item at index (default last).
| Raises IndexError if list is empty or index is out of range.
删除index位置处的对象并返回该对象,列表本身改变
In [92]: a.pop(2)Out[92]: 2In [93]: aOut[93]: ['abc', 1, 3, 1, 2, 3, 4, 5, 6]
remove(...)
| L.remove(value) -> None -- remove first occurrence of value.
| Raises ValueError if the value is not present.
删除某个第一次出现的值,返回None
In [100]: a = [1,1,2,2,3,3,4,4,"aa",'aa']In [101]: a.remove(1)In [102]: aOut[102]: [1, 2, 2, 3, 3, 4, 4, 'aa', 'aa']In [103]: a.remove('aa')In [104]: aOut[104]: [1, 2, 2, 3, 3, 4, 4, 'aa']
reverse(...)
| L.reverse() -- reverse *IN PLACE* 列表逆序
In [105]: a = [1,2,3]In [106]: a.reverse()In [107]: aOut[107]: [3, 2, 1]
sort(...) 对列表进行排序,列表元素必须是同一类型
| L.sort(key=None, reverse=False) -> None -- stable sort *IN PLACE*
In [112]: a = [1,9,2,3,7,4]In [113]: a.sort()In [114]: aOut[114]: [1, 2, 3, 4, 7, 9]
阅读全文
0 0
- Python学习笔记(一):list属性及方法浅析
- Python学习笔记(二):tuple属性及方法浅析
- Python学习笔记(一):LIST数据类型
- Python学习笔记一之列表list
- python学习笔记(属性和方法)
- HTML5_Canvas_属性、定义及方法(学习笔记)
- python学习笔记--list
- python学习笔记--List
- 学习笔记一(List)
- Python学习笔记一:列表方法
- Python学习笔记——list的常用方法
- Python 基础学习笔记2(List 的 append , extend方法)
- shader学习笔记<一>: 属性及变量声明
- python笔记--List合并方法
- 《Python基础教程》学习笔记之[D11]魔法方法、属性、迭代器
- Python学习笔记(面向对象-类-方法-属性)
- Python学习笔记(九)魔法方法,属性和迭代器
- 《Python基础教程》学习笔记 Chp9 魔法方法、属性和迭代器
- 页面内容跟随屏幕分辨率,不随窗口缩放而变化
- 矩阵的线性变换
- java并发【转】
- String字符串拼接符 “+”底层原理
- linux 常用命令安装及操作
- Python学习笔记(一):list属性及方法浅析
- 列表、元组及通用序列操作
- 常用数据结构之一队列
- 【C# in depth 第三版】温故而知新(1)
- 聚簇索引和非聚簇索引详解
- Hadoop1安装
- Python机器学习——DBSCAN聚类
- PHP基于数组实现的分页函数实例,可作为方法使用
- VC中MessageBox与AfxMessageBox用法与区别