重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
实例方法
定义:第一个参数必须是实例对象,该参数名一般约定为“self”,通过它来传递实例的属性和方法(也可以传类的属性和方法);
调用:只能由实例对象调用。
成都创新互联服务项目包括岐山网站建设、岐山网站制作、岐山网页制作以及岐山网络营销策划等。多年来,我们专注于互联网行业,利用自身积累的技术优势、行业经验、深度合作伙伴关系等,向广大中小型企业、政府机构等提供互联网行业的解决方案,岐山网站推广取得了明显的社会效益与经济效益。目前,我们服务的客户以成都为中心已经辐射到岐山省份的部分城市,未来相信会继续扩大服务区域并继续获得客户的支持与信任!
类方法
定义:使用装饰器@classmethod。第一个参数必须是当前类对象,该参数名一般约定为“cls”,通过它来传递类的属性和方法(不能传实例的属性和方法);
调用:实例对象和类对象都可以调用。
静态方法
定义:使用装饰器@staticmethod。参数随意,没有“self”和“cls”参数,但是方法体中不能使用类或实例的任何属性和方法;
调用:实例对象和类对象都可以调用。
备注:MAC 安装pygame报错
liangkai@ttys000 $ pip install pygame
Collecting pygame
Using cached https://files.pythonhosted.org/packages/b2/6b/c510f0853765eb2219ca5aa3d416d65bb0dea7cd9bb2984aea0a0e04c24d/pygame-1.9.4.tar.gz
Building wheels for collected packages: pygame
Running setup.py bdist_wheel for pygame ... error
Complete output from command /Library/Frameworks/Python.framework/Versions/3.5/bin/python3 -u -c "import setuptools, tokenize;__file__='/private/var/folders/1t/l_shx33n0911n3673wmdkl980000gr/T/pip-install-l6ap1uos/pygame/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /private/var/folders/1t/l_shx33n0911n3673wmdkl980000gr/T/pip-wheel-7s7vp6w0 --python-tag cp35:
...............
building 'pygame.sdlmain_osx' extension
/usr/bin/clang -fno-strict-aliasing -Wsign-compare -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch i386 -arch x86_64 -g -Ddarwin -D_THREAD_SAFE -DENABLE_NEWBUF=1 -I/usr/X11R6/include -I/usr/local/include/SDL -I/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m -c src/sdlmain_osx.m -o build/temp.macosx-10.6-intel-3.5/src/sdlmain_osx.o
In file included from src/sdlmain_osx.m:24:
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Carbon.framework/Headers/Carbon.h:34:10: fatal error: 'CarbonSound/CarbonSound.h' file not found
#include
^~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
---
For help with compilation see:
https://www.pygame.org/wiki/MacCompile
To contribute to pygame development see:
https://www.pygame.org/contribute.html
---
error: command '/usr/bin/clang' failed with exit status 1
----------------------------------------
Command "/Library/Frameworks/Python.framework/Versions/3.5/bin/python3 -u -c "import setuptools, tokenize;__file__='/private/var/folders/1t/l_shx33n0911n3673wmdkl980000gr/T/pip-install-l6ap1uos/pygame/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /private/var/folders/1t/l_shx33n0911n3673wmdkl980000gr/T/pip-record-f5kt4tgo/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/1t/l_shx33n0911n3673wmdkl980000gr/T/pip-install-l6ap1uos/pygame/
解决方法:
pip install pygame==1.9.2