您好,登錄后才能下訂單哦!
實(shí)例方法
定義:第一個(gè)參數(shù)必須是實(shí)例對(duì)象,該參數(shù)名一般約定為“self”,通過它來傳遞實(shí)例的屬性和方法(也可以傳類的屬性和方法);
調(diào)用:只能由實(shí)例對(duì)象調(diào)用。
類方法
定義:使用裝飾器@classmethod。第一個(gè)參數(shù)必須是當(dāng)前類對(duì)象,該參數(shù)名一般約定為“cls”,通過它來傳遞類的屬性和方法(不能傳實(shí)例的屬性和方法);
調(diào)用:實(shí)例對(duì)象和類對(duì)象都可以調(diào)用。
靜態(tài)方法
定義:使用裝飾器@staticmethod。參數(shù)隨意,沒有“self”和“cls”參數(shù),但是方法體中不能使用類或?qū)嵗娜魏螌傩院头椒ǎ?br/>調(diào)用:實(shí)例對(duì)象和類對(duì)象都可以調(diào)用。
備注:MAC 安裝pygame報(bào)錯(cuò)
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 <CarbonSound/CarbonSound.h>
^~~~~~~~~~~~~~~~~~~~~~~~~~~
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
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。