\u76ee\u5f55<\/strong><\/p>\n\u547d\u540d\u53c2\u8003\u7f51\u7ad9<\/p>\n
Python\u547d\u540d\u89c4\u5219<\/p>\n
1\u3001\u5305\u547d\u540d mypackage\uff0cpackage_name <\/p>\n
2\u3001\u6a21\u5757\u547d\u540d mymodule.py\uff0cmodule_name.py <\/p>\n
3\u3001\u7c7b\u547d\u540d MyClass\uff0cClassName<\/p>\n
4\u3001\u51fd\u6570\u547d\u540d <\/p>\n
1\uff09\u666e\u901a\u51fd\u6570 myfunction()\uff0cmy_function_name()<\/p>\n
2\uff09\u79c1\u6709\u51fd\u6570\uff08\u5916\u90e8\u8bbf\u95ee\u4f1a\u62a5\u9519\uff09 __get_name() <\/p>\n
3\uff09\u51fd\u6570\u548c\u65b9\u6cd5\u7684\u53c2\u6570 parameter\uff0cfunction_parameter_name<\/p>\n
5\u3001\u53d8\u91cf\u547d\u540d<\/p>\n
\u53d8\u91cf\u5b9a\u4e49<\/p>\n
1\uff09\u7c7b\u53d8\u91cf\uff08\u5168\u5c40\u53d8\u91cf\u540d\uff09 COLOR_WRITE\uff0cGLOBAL_VAR_NAME<\/p>\n
2\uff09\u5e38\u91cf MAX_OVERFLOW\uff0cTOTAL<\/p>\n
3\uff09\u666e\u901a\u53d8\u91cf this_is_a_var \uff0clocal_var_name<\/p>\n
4\uff09\u5b9e\u4f8b\u53d8\u91cf _instance_var<\/p>\n
5\uff09\u79c1\u6709\u5b9e\u4f8b\u53d8\u91cf\uff08\u5916\u90e8\u8bbf\u95ee\u4f1a\u62a5\u9519\uff09 __private_var<\/p>\n
6\uff09\u4e13\u6709\u53d8\u91cf __class__ <\/p>\n
6\u3001\u5f02\u5e38\u547d\u540d ExceptionNameError<\/p>\n
7\u3001\u7f29\u5199 <\/p>\n
8\u3001\u524d\u5bfc\u540e\u7f00\u4e0b\u5212\u7ebf<\/p>\n
9\u3001Python\u5173\u952e\u5b57<\/p>\n
10\u3001Python\u5185\u7f6e\u51fd\u6570<\/p>\n
Python\u4ee3\u7801\u89c4\u8303<\/p>\n
1\u3001\u4ee3\u7801\u884c\u957f\u5ea6<\/p>\n
2\u3001\u5f15\u53f7\u7684\u4f7f\u7528<\/p>\n
3\u3001\u7a7a\u884c\u7684\u4f7f\u7528<\/p>\n
1\uff09\u6a21\u5757\u4e2d\uff0c\u51fd\u6570\uff0c\u7c7b\u5b9a\u4e49\u4e4b\u95f4\uff0c\u7a7a2\u884c<\/p>\n
2\uff09\u7c7b\u6210\u5458\u51fd\u6570\u4e4b\u95f4\uff0c\u7a7a1\u884c <\/p>\n
3\uff09\u5728\u4e8c\u5143\u8fd0\u7b97\u7b26\u4e24\u8fb9\uff0c\u5404\u7a7a\u4e00\u683c [=,-,+=,==,>,in,is not, and]<\/p>\n
4\uff09\u51fd\u6570\u7684\u53c2\u6570\u5217\u8868\u4e2d\uff0c\u9017\u53f7\u4e4b\u540e\uff0c\u8981\u6709\u7a7a\u683c<\/p>\n
5\uff09\u51fd\u6570\u7684\u53c2\u6570\u5217\u8868\u4e2d\uff0c\u9ed8\u8ba4\u503c\u7b49\u53f7\u4e24\u8fb9\uff0c\u4e0d\u8981\u6dfb\u52a0\u7a7a\u683c<\/p>\n
6\uff09\u5de6\u62ec\u53f7\u4e4b\u540e\uff0c\u53f3\u62ec\u53f7\u4e4b\u524d\uff0c\u4e0d\u8981\u52a0\u591a\u4f59\u7684\u7a7a\u683c<\/p>\n
7\uff09\u5b57\u5178\u5bf9\u8c61\u7684\u5de6\u62ec\u53f7\u4e4b\u524d\uff0c\u4e0d\u8981\u591a\u4f59\u7684\u7a7a\u683c<\/p>\n
8\uff09\u4e0d\u8981\u4e3a\u5bf9\u9f50\u8d4b\u503c\u8bed\u53e5\uff0c\u800c\u4f7f\u7528\u989d\u5916\u7a7a\u683c<\/p>\n
4\u3001import \u8bed\u53e5<\/p>\n
1\uff09\u5355\u72ecimport\u65f6\uff0c\u4e0d\u8981\u5728\u4e00\u884c\u5bfc\u5165\u591a\u4e2a\uff1b<\/p>\n
2\uff09from ... import\u53ef\u4ee5\u5728\u4e00\u884c\u5bfc\u5165\u591a\u4e2a<\/p>\n
3\uff09import\u8bed\u53e5\u5e94\u8be5\u4f7f\u7528 absolute import<\/p>\n
4\uff09import\u8bed\u53e5\u4e66\u5199\u4f4d\u7f6e<\/p>\n
5\uff09\u5982\u679c\u53d1\u751f\u547d\u540d\u51b2\u7a81\uff0c\u5219\u53ef\u4f7f\u7528\u547d\u540d\u7a7a\u95f4<\/p>\n
5\u3001\u6362\u884c<\/p>\n
1\uff09\u7981\u6b62\u590d\u5408\u8bed\u53e5\uff0c\u5373\u4e00\u884c\u4e2d\u5305\u542b\u591a\u4e2a\u8bed\u53e5<\/p>\n
2\uff09if\/for\/while\u4e00\u5b9a\u8981\u6362\u884c<\/p>\n
3\uff09\u652f\u6301\u62ec\u53f7\u5185\u7684\u6362\u884c<\/p>\n
4\uff09\u4f7f\u7528\u53cd\u659c\u6760\\\u6362\u884c\uff0c\u4e8c\u5143\u8fd0\u7b97\u7b26+ .\u7b49\u5e94\u51fa\u73b0\u5728\u884c\u672b<\/p>\n
6\u3001\u6ce8\u91ca<\/p>\n
1\uff09\u5757\u6ce8\u91ca<\/p>\n
2\uff09\u884c\u6ce8\u91ca<\/p>\n
3\uff09\u6587\u6863\u6ce8\u91ca\uff08Docstring\uff09<\/p>\n
4\uff09\u91cd\u8981\u7684\u6ce8\u91ca<\/p>\n
7\u3001\u6a21\u5757<\/p>\n
\n\u547d\u540d\u53c2\u8003\u7f51\u7ad9<\/h2>\n\n- codeif\uff1ahttps:\/\/unbug.github.io\/codelf\/<\/li>\n
- \u53d8\u91cf\u547d\u540d\u52a9\u624b\uff1ahttp:\/\/www.gjw123.com\/tools-blzs<\/li>\n<\/ul>\n
<\/p>\n
Python\u547d\u540d\u89c4\u5219<\/h2>\n\n- \u6807\u8bc6\u7b26\uff0c\u5fc5\u987b\u4ee5\u5b57\u6bcd\u3001\u4e0b\u753b\u7ebf\uff08_\uff09\u5f00\u5934<\/strong>\uff08\u6570\u5b57\u4e0d\u80fd\u6253\u5934\uff09\uff0c\u540e\u9762\u53ef\u4ee5\u8ddf\u4efb\u610f\u6570\u76ee\u7684\u5b57\u6bcd\u3001\u6570\u5b57\u548c\u4e0b\u753b\u7ebf\uff08_\uff09<\/strong>\u3002<\/li>\n
- \u5b57\u6bcd\u5e76\u4e0d\u5c40\u9650\u4e8e 26 \u4e2a\u82f1\u6587\u5b57\u6bcd\uff0c\u53ef\u4ee5\u5305\u542b\u4e2d\u6587\u5b57\u7b26<\/strong>\u3001\u65e5\u6587\u5b57\u7b26\u7b49\u3002<\/li>\n
- Python \u8bed\u8a00\u662f\u533a\u5206\u5927\u5c0f\u5199<\/strong>\u7684\uff0c\u56e0\u6b64 abc \u548c Abc \u662f\u4e24\u4e2a\u4e0d\u540c\u7684\u6807\u8bc6\u7b26\u3002<\/li>\n
- \u6807\u8bc6\u7b26\u4e0d\u80fd\u662f Python \u5173\u952e\u5b57\uff0c\u4f46\u53ef\u4ee5\u5305\u542b\u5173\u952e\u5b57\u3002<\/li>\n
- \u6807\u8bc6\u7b26\u4e0d\u80fd\u5305\u542b\u7a7a\u683c<\/strong>\u3002<\/li>\n
- Python 3 \u652f\u6301 UTF-8 \u5b57\u7b26\u96c6\uff0c\u56e0\u6b64 Python 3 \u7684\u6807\u8bc6\u7b26\u53ef\u4ee5\u4f7f\u7528 UTF-8 \u6240\u80fd\u8868\u793a\u7684\u591a\u79cd\u8bed\u8a00\u7684\u5b57\u7b26<\/strong><\/li>\n
- Python 2.x \u5bf9\u4e2d\u6587\u652f\u6301\u8f83\u5dee\uff0c\u5982\u679c\u8981\u5728 Python 2.x \u7a0b\u5e8f\u4e2d\u4f7f\u7528\u4e2d\u6587\u5b57\u7b26\u6216\u4e2d\u6587\u53d8\u91cf\uff0c\u5219\u9700\u8981\u5728 Python \u6e90\u7a0b\u5e8f\u7684\u7b2c\u4e00\u884c\u589e\u52a0\u201c#coding:utf-8\u201d\uff0c\u5f53\u7136\u522b\u5fd8\u4e86\u5c06\u6e90\u6587\u4ef6\u4fdd\u5b58\u4e3a UTF-8 \u5b57\u7b26\u96c6<\/li>\n<\/ul>\n
<\/p>\n
\u6807\u8bc6\u7b26\u4f8b\u5b50\uff1a<\/strong><\/p>\n\n- abc_xyz\uff1a\u5408\u6cd5\u3002<\/li>\n
- HelloWorld\uff1a\u5408\u6cd5\u3002<\/li>\n
- abc\uff1a\u5408\u6cd5\u3002<\/li>\n
- xyz#abc\uff1a\u4e0d\u5408\u6cd5\uff0c\u6807\u8bc6\u7b26\u4e2d\u4e0d\u5141\u8bb8\u51fa\u73b0\u201c#\u201d\u53f7\u3002<\/li>\n
- abc1\uff1a\u5408\u6cd5\u3002<\/li>\n
- 1abc\uff1a\u4e0d\u5408\u6cd5\uff0c\u6807\u8bc6\u7b26\u4e0d\u5141\u8bb8\u6570\u5b57\u5f00\u5934\u3002<\/li>\n<\/ul>\n
<\/p>\n
1\u3001\u5305\u547d\u540d mypackage\uff0cpackage_name <\/h3>\n\n- \u5c0f\u5199<\/strong><\/span>\u5b57\u6bcd\uff1b<\/li>\n
- \u53ef\u4f7f\u7528\u4e0b\u5212\u7ebf\uff0c\u5355\u8bcd\u4e4b\u95f4\u7528_\u5206\u5272\uff1b<\/li>\n
- \u5982\uff1amypackage\uff0cmy_package<\/li>\n<\/ul>\n
<\/p>\n
2\u3001\u6a21\u5757\u547d\u540d mymodule.py\uff0cmodule_name.py <\/h3>\n\n- \u5c0f\u5199<\/strong><\/span>\u5b57\u6bcd\uff1b<\/li>\n
- \u53ef\u4f7f\u7528\u4e0b\u5212\u7ebf\uff0c\u5355\u8bcd\u4e4b\u95f4\u7528_\u5206\u5272\uff1b<\/li>\n
- \u5982\uff1amymodule.py\uff0cad_stats.py<\/li>\n<\/ul>\n
<\/p>\n
3\u3001\u7c7b\u547d\u540d MyClass\uff0cClassName<\/h3>\n\n- \u5355\u8bcd\u9996\u5b57\u6bcd\u5927\u5199<\/span><\/strong>\uff1b<\/li>\n
- \u5982\uff1aAdStats\uff0cConfigUtil\uff0cMyClass<\/li>\n
- \u5185\u90e8\u7c7b<\/strong><\/span>\uff1a\u53ef\u4ee5\u4f7f\u7528\u989d\u5916\u7684\u524d\u5bfc\u4e0b\u5212\u7ebf<\/strong><\/span>\uff1b<\/strong><\/li>\n
- \u5982\uff1a__MyClass<\/strong><\/span><\/li>\n
- \u57fa\u7c7b\uff1a<\/strong><\/span>\u4f7f\u7528Base\u6216Abstract\u524d\u7f00\uff0c\u5982\uff1aCamelBase<\/li>\n<\/ul>\n
<\/p>\n
4\u3001\u51fd\u6570\u547d\u540d <\/h3>\n1\uff09\u666e\u901a\u51fd\u6570 myfunction()\uff0cmy_function_name()<\/h4>\n\n- \u5c0f\u5199<\/strong><\/span>\u5b57\u6bcd\uff1b<\/li>\n
- \u53ef\u4f7f\u7528\u4e0b\u5212\u7ebf\uff0c\u5355\u8bcd\u4e4b\u95f4\u7528_\u5206\u5272\uff1b<\/li>\n
- \u5982\uff1amyfunction()\uff0cmy_example_function()\uff0cget_name() \uff0ccount_number() \uff0cad_stat() <\/li>\n<\/ul>\n
<\/p>\n
2\uff09\u79c1\u6709\u51fd\u6570\uff08\u5916\u90e8\u8bbf\u95ee\u4f1a\u62a5\u9519\uff09 __get_name() <\/h4>\n\n- \u4ee5__\u5f00\u5934<\/strong><\/span>\uff082\u4e2a\u4e0b\u5212\u7ebf\uff09<\/li>\n
- \u5c0f\u5199<\/strong><\/span>\u5b57\u6bcd\uff1b<\/li>\n
- \u53ef\u4f7f\u7528\u4e0b\u5212\u7ebf\uff0c\u5355\u8bcd\u4e4b\u95f4\u7528_\u5206\u5272\uff1b<\/li>\n
- \u5982\uff1a__get_name() <\/li>\n<\/ul>\n
3\uff09\u51fd\u6570\u548c\u65b9\u6cd5\u7684\u53c2\u6570 parameter\uff0cfunction_parameter_name<\/h4>\n\n- \u4f7f\u7528 self <\/strong>\u4f5c\u4e3a\u5b9e\u4f8b\u65b9\u6cd5<\/strong><\/span>\u7684\u7b2c\u4e00\u4e2a\u53c2\u6570<\/strong>\uff1b<\/li>\n
- \u4f7f\u7528 cls <\/strong>\u4f5c\u4e3a\u7c7b\u65b9\u6cd5<\/strong><\/span>\u7684\u7b2c\u4e00\u4e2a\u53c2\u6570\uff1b<\/strong><\/li>\n
- \u5982\u679c\u51fd\u6570\u7684\u53c2\u6570\u540d\u79f0\uff0c\u548c\u4fdd\u7559\u7684\u5173\u952e\u5b57\u51b2\u7a81\uff0c\u901a\u5e38\u4f7f\u7528\u4e00\u4e2a\u540e\u7f00\u4e0b\u5212\u7ebf<\/strong>\u597d\u4e8e\u4f7f\u7528\u7f29\u5199\u6216\u5947\u602a\u7684\u62fc\u5199\uff1b<\/li>\n
- \u7f3a\u7701\u503c\u7b49\u53f7\u4e24\u8fb9\u65e0\u7a7a\u683c\uff1bdef func(self, user=None):<\/li>\n<\/ul>\n
<\/p>\n
5\u3001\u53d8\u91cf\u547d\u540d<\/h3>\n\u53d8\u91cf\u5b9a\u4e49<\/h4>\n\n- \u5168\u5c40\u53d8\u91cf\uff1a<\/strong>\u5c5e\u4e8e\u6a21\u5757\u7684\u5c5e\u6027\uff0c\u5728\u6a21\u5757\u5185\u3001\u6240\u6709\u51fd\u6570\u5916\u3001\u5728class\u5916<\/strong>\uff0c\u8fd9\u662f\u5168\u5c40\u53d8\u91cf\uff1b<\/li>\n
- \u5c40\u90e8\u53d8\u91cf\uff1a<\/strong>\u5728\u51fd\u6570\u5185<\/strong>\u3001\u5728class\u7684\u65b9\u6cd5<\/strong>\uff08\u6784\u9020\u3001\u7c7b\u65b9\u6cd5\u3001\u9759\u6001\u65b9\u6cd5\u3001\u5b9e\u4f8b\u65b9\u6cd5\uff09\u5185\uff08\u53d8\u91cf\u672a\u52a0self\u4fee\u9970\uff09\uff0c\u8fd9\u662f\u5c40\u90e8\u53d8\u91cf<\/li>\n
- \u7c7b\u53d8\u91cf\uff1a<\/strong>\u5c5e\u4e8e\u7c7b\u7684\u5c5e\u6027\uff0c\u5728class\u5185\uff0c\u4e14\u4e0d\u5728class\u7684\u65b9\u6cd5\u5185<\/strong>\uff0c\u8fd9\u662f\u7c7b\u53d8\u91cf<\/li>\n
- \u5b9e\u4f8b\u53d8\u91cf\uff1a<\/strong>\u5c5e\u4e8e\u5bf9\u8c61\u7684\u5c5e\u6027\uff0c\u5728class\u7684\u65b9\u6cd5\u5185<\/strong>\uff0c\u4e14\u4f7f\u7528self\u4fee\u9970\u7684\u53d8\u91cf<\/strong>\uff0c\u8fd9\u662f\u5b9e\u4f8b\u53d8\u91cf<\/li>\n<\/ul>\n
\u6ce8\u610f\u8bf4\u660e\uff1a<\/strong><\/p>\n\n- \u5982\u679c\u5c40\u90e8\u53d8\u91cf<\/strong>\u4e0e\u5168\u5c40\u53d8\u91cf\u540c\u540d<\/strong>\uff0c\u90a3\u4e48\u65b9\u6cd5\u6216\u8005\u51fd\u6570\u4e2d\u5c06\u4f18\u5148\u4f7f\u7528<\/strong>\u7684\u662f\u5c40\u90e8\u53d8\u91cf\u7684\u503c<\/strong>\uff0c\u800c\u4e0d\u662f\u4f7f\u7528\u5168\u5c40\u53d8\u91cf\uff1b<\/li>\n
- global\u5173\u952e\u5b57\uff0c\u663e\u5f0f\u7684\u5f15\u7528\u5168\u5c40\u53d8\u91cf\uff1b<\/li>\n<\/ul>\n
<\/p>\n
1\uff09\u7c7b\u53d8\u91cf\uff08\u5168\u5c40\u53d8\u91cf\u540d\uff09 COLOR_WRITE\uff0cGLOBAL_VAR_NAME<\/h4>\n\n- \u5927\u5199<\/strong><\/span>\u5b57\u6bcd\uff1b<\/li>\n
- \u5355\u8bcd\u4e4b\u95f4\u7528_\u5206\u5272\uff1b<\/li>\n
- \u5728java\u4e2d\u76f8\u5f53\u4e8estatic\u9759\u6001\u53d8\u91cf<\/strong>\uff1b<\/li>\n
- \u5982\uff1aNUMBER\uff0cCOLOR_WRITE<\/li>\n<\/ul>\n
<\/p>\n
2\uff09\u5e38\u91cf MAX_OVERFLOW\uff0cTOTAL<\/h4>\n\n- \u5927\u5199<\/strong><\/span>\u5b57\u6bcd\uff1b<\/li>\n
- \u5355\u8bcd\u4e4b\u95f4\u7528_\u5206\u5272\uff1b<\/li>\n
- \u5982\uff1aMAX_OVERFLOW\uff0cTOTAL<\/li>\n<\/ul>\n
<\/p>\n
3\uff09\u666e\u901a\u53d8\u91cf this_is_a_var \uff0clocal_var_name<\/h4>\n\n- \u5c0f\u5199<\/strong><\/span>\u5b57\u6bcd\uff1b<\/li>\n
- \u53ef\u4f7f\u7528\u4e0b\u5212\u7ebf\uff0c\u5355\u8bcd\u4e4b\u95f4\u7528_\u5206\u5272\uff1b<\/li>\n
- \u5982\uff1athis_is_a_var <\/li>\n<\/ul>\n
4\uff09\u5b9e\u4f8b\u53d8\u91cf _instance_var<\/h4>\n\n- \u4ee5_\u5f00\u5934<\/strong><\/span>\uff081\u4e2a\u4e0b\u5212\u7ebf\uff09<\/li>\n
- \u5c0f\u5199<\/strong><\/span>\u5b57\u6bcd\uff1b<\/li>\n
- \u53ef\u4f7f\u7528\u4e0b\u5212\u7ebf\uff0c\u5355\u8bcd\u4e4b\u95f4\u7528_\u5206\u5272\uff1b<\/li>\n
- \u5982\uff1a_price \uff0c_instance_var <\/li>\n<\/ul>\n
5\uff09\u79c1\u6709\u5b9e\u4f8b\u53d8\u91cf\uff08\u5916\u90e8\u8bbf\u95ee\u4f1a\u62a5\u9519\uff09 __private_var<\/h4>\n\n- \u4ee5__\u5f00\u5934<\/strong><\/span>\uff082\u4e2a\u4e0b\u5212\u7ebf\uff09<\/li>\n
- \u5c0f\u5199<\/strong><\/span>\u5b57\u6bcd\uff1b<\/li>\n
- \u53ef\u4f7f\u7528\u4e0b\u5212\u7ebf\uff0c\u5355\u8bcd\u4e4b\u95f4\u7528_\u5206\u5272\uff1b<\/li>\n
- \u5982\uff1a__price \uff0c__private_var<\/li>\n<\/ul>\n
<\/p>\n
6\uff09\u4e13\u6709\u53d8\u91cf __class__ <\/h4>\n\n- __\u5f00\u5934\uff0c__\u7ed3\u5c3e\uff1b<\/li>\n
- \u4e00\u822c\u4e3apython\u7684\u81ea\u6709\u53d8\u91cf\uff0c\u5f00\u53d1\u4e0d\u8981\u4ee5\u8fd9\u79cd\u65b9\u5f0f\u547d\u540d\uff1b<\/li>\n
- \u5982\uff1a__doc__ \uff0c__class__ <\/li>\n<\/ul>\n
<\/p>\n
6\u3001\u5f02\u5e38\u547d\u540d ExceptionNameError<\/strong><\/h3>\n\n- \u4ee5 Error \u4f5c\u4e3a\u540e\u7f00\uff1b<\/strong> <\/li>\n<\/ul>\n
<\/p>\n
7\u3001\u7f29\u5199 <\/h3>\n\n- \u547d\u540d\u5e94\u5f53\u5c3d\u91cf\u4f7f\u7528\u5168\u62fc\u5199\u7684\u5355\u8bcd<\/strong>\uff1b<\/li>\n
- \u5e38\u7528\u7684\u7f29\u5199\uff0c\u5982XML\u3001ID\u7b49\uff0c\u5728\u547d\u540d\u65f6\u4e5f\u5e94\u53ea\u5927\u5199\u9996\u5b57\u6bcd<\/strong>\uff0c\u5982XmlParser<\/li>\n
- \u547d\u540d\u4e2d\u542b\u6709\u957f\u5355\u8bcd\uff0c\u5bf9\u67d0\u4e2a\u5355\u8bcd\u8fdb\u884c\u7f29\u5199\uff0c\u5e94\u4f7f\u7528\u7ea6\u5b9a\u6210\u4fd7\u7684\u7f29\u5199\u65b9\u5f0f<\/strong>\uff1b<\/li>\n
- \u5982\uff1a\n
\n- function \u7f29\u5199\u4e3a fn <\/li>\n
- text \u7f29\u5199\u4e3a txt <\/li>\n
- object \u7f29\u5199\u4e3a obj <\/li>\n
- count \u7f29\u5199\u4e3a cnt <\/li>\n
- number \u7f29\u5199\u4e3a num<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n
<\/p>\n
8\u3001\u524d\u5bfc\u540e\u7f00\u4e0b\u5212\u7ebf<\/h3>\n\n- Python \u7528\u4e0b\u5212\u7ebf<\/strong>\uff0c\u4f5c\u4e3a\u53d8\u91cf\u524d\u7f00<\/strong>\u548c\u540e\u7f00\uff0c<\/strong>\u6307\u5b9a\u7279\u6b8a\u53d8\u91cf<\/strong><\/span>\uff1b<\/li>\n
- \u4e00\u4e2a\u524d\u5bfc\u4e0b\u5212\u7ebf\uff1a<\/strong>\u8868\u793a\u975e\u516c\u6709<\/strong><\/span>\uff0c\u662f\u79c1\u6709\u7684<\/strong><\/span>\uff0c\u5982\uff1a_myprice \uff0c_foo\n
\n- \u5728\u6a21\u5757\u6216\u7c7b\u5916<\/strong>\u4e0d\u53ef\u4ee5\u4f7f\u7528\uff0c\u53ea\u6709\u7c7b\u5bf9\u8c61<\/strong>\u548c\u5b50\u7c7b\u5bf9\u8c61<\/strong>\u81ea\u5df1\u80fd\u8bbf\u95ee\u5230\u8fd9\u4e9b\u53d8\u91cf\uff1b<\/li>\n
- \u4e0d\u80fd\u76f4\u63a5\u8bbf\u95ee\u7684\u7c7b\u5c5e\u6027<\/strong>\uff0c\u9700\u901a\u8fc7\u7c7b\u63d0\u4f9b\u7684\u63a5\u53e3<\/strong>\u8fdb\u884c\u8bbf\u95ee\uff1b<\/li>\n
- _xxx \u4e0d\u80fd\u7528'from module import *'\u5bfc\u5165 <\/li>\n<\/ul>\n<\/li>\n
- \u4e00\u4e2a\u540e\u7f00\u4e0b\u5212\u7ebf\uff1a<\/strong>\u907f\u514d\u5173\u952e\u5b57\u51b2\u7a81<\/strong><\/span>\uff0c\u5982\uff1acount_<\/li>\n
- \u4e24\u4e2a\u524d\u5bfc\u4e0b\u5212\u7ebf\uff1a<\/strong>\u5f53\u547d\u540d\u4e00\u4e2a\u7c7b\u5c5e\u6027<\/strong>\u5f15\u8d77\u540d\u79f0\u51b2\u7a81\u65f6\u4f7f\u7528\uff0c\u4e5f\u53ef\u80fd\u662f\u79c1\u6709\u6210\u5458\uff0c\u5982\uff1a__name\uff0c __foo\n
\n- \u53ea\u6709\u7c7b\u5bf9\u8c61\u81ea\u5df1\u80fd\u8bbf\u95ee<\/strong>\uff0c\u8fde\u5b50\u7c7b\u5bf9\u8c61<\/strong><\/span>\u4e5f\u4e0d\u80fd\u8bbf\u95ee<\/span>\u5230\u8fd9\u4e2a\u6570\u636e\uff1b<\/strong><\/li>\n
- \u7c7b\u4e2d\u7684\u79c1\u6709\u53d8\u91cf\u540d<\/li>\n
- <\/li>\n<\/ul>\n<\/li>\n
- \u4e24\u4e2a\u524d\u5bfc\u548c\u540e\u7f00\u4e0b\u5212\u7ebf\uff1a\u201c\u9b54\u201d<\/strong>\uff08\u6709\u7279\u6b8a\u7528\u9014\uff09\u5bf9\u8c61<\/strong>\u6216\u8005\u5c5e\u6027<\/strong>\uff0c\u5982\uff1a__init__\uff08\uff09\u4ee3\u8868\u7c7b\u7684\u6784\u9020\u51fd\u6570\uff0c\u6216\u8005__file__ \n
\n- \u4e00\u822c\u662f\u7cfb\u7edf\u5b9a\u4e49\u540d\u5b57\uff0c\u7cfb\u7edf\u4fdd\u7559\u5b57\u547d\u540d\u6cd5\uff1b<\/li>\n
- \u7edd\u5bf9\u4e0d\u8981\u521b\u9020\u8fd9\u6837\u7684\u540d\u5b57\uff0c\u800c\u53ea\u662f\u4f7f\u7528\u5b83\u4eec\uff1b<\/li>\n
- \u9879\u76ee\u4e2d\u53ef\u4ee5\u4f7f\u7528\u8fd9\u79cd\u547d\u540d\uff0c\u5b83\u7684\u610f\u4e49\u5728\u4e8e\u8fd9\u79cd\u5f62\u5f0f\u7684\u53d8\u91cf\u662f\u53ea\u8bfb\u7684\uff0c\u8fd9\u79cd\u5f62\u5f0f\u7684\u7c7b\u6210\u5458\u51fd\u6570\u5c3d\u91cf\u4e0d\u8981\u91cd\u8f7d<\/strong>\uff1b\u5982\uff1a\n
\n- \u5176\u4e2d __id__\u3001__parent__ \u548c __message__ \u90fd\u91c7\u7528\u4e86\u7cfb\u7edf\u4fdd\u7559\u5b57\u547d\u540d\u6cd5\uff1b<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n
class Base(object): \n def __init__(self, id, parent = None): \n self.__id__ = id \n self.__parent__ = parent \n def __message__(self, msgid): <\/code><\/pre>\n <\/p>\n
\u6ce8\u610f\u8bf4\u660e\uff1a<\/strong><\/p>\n\u4e0b\u5212\u7ebf\uff0c<\/strong><\/span>\u5bf9\u89e3\u91ca\u5668\u6709\u7279\u6b8a\u7684\u610f\u4e49\uff0c\u662f\u5185\u5efa\u6807\u8bc6\u7b26\u6240\u4f7f\u7528\u7684\u7b26\u53f7\uff0c\u5efa\u8bae\u7a0b\u5e8f\u5458\u907f\u514d\u7528\u4e0b\u5212\u7ebf<\/strong>\u4f5c\u4e3a\u53d8\u91cf\u540d\u7684\u5f00\u59cb<\/strong>\uff1b
<\/p>\n9\u3001Python\u5173\u952e\u5b57<\/h3>\n\n- \u5982\u679c\u5f00\u53d1\u8005\u5c1d\u8bd5\u4f7f\u7528\u5173\u952e\u5b57\u4f5c\u4e3a\u53d8\u91cf\u540d\uff0cPython \u89e3\u91ca\u5668\u4f1a\u62a5\u9519\u3002<\/li>\n<\/ul>\n
\u67e5\u770b\u5173\u952e\u5b57\uff1a<\/strong><\/p>\n#\u5bfc\u5165keyword \u6a21\u5757\nimport keyword\n#\u663e\u793a\u6240\u6709\u5173\u952e\u5b57\nkeyword.kwlist<\/code><\/pre>\n\u8f93\u51fa\u7ed3\u679c\uff1a<\/strong><\/p>\n['False', 'None', 'True', 'and', 'as', 'assert', 'async', 'await', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield']\n<\/code><\/pre>\n <\/p>\n
10\u3001Python\u5185\u7f6e\u51fd\u6570<\/h3>\n\n- \u5982\u679c\u5f00\u53d1\u8005\u4f7f\u7528\u5185\u7f6e\u51fd\u6570\u7684\u540d\u5b57\u4f5c\u4e3a\u53d8\u91cf\u540d\uff0cPython \u89e3\u91ca\u5668\u5012\u4e0d\u4f1a\u62a5\u9519\uff0c\u53ea\u662f\u8be5\u5185\u7f6e\u51fd\u6570\u5c31\u88ab\u8fd9\u4e2a\u53d8\u91cf\u8986\u76d6\u4e86\uff0c\u8be5\u5185\u7f6e\u51fd\u6570\u5c31\u4e0d\u80fd\u4f7f\u7528\u4e86\u3002<\/li>\n<\/ul>\n
\n\n Python\u5185\u7f6e\u51fd\u6570
\n <\/caption>\n\n\nabs()<\/td>\n | all()<\/td>\n | any()<\/td>\n | basestring()<\/td>\n | bin()<\/td>\n<\/tr>\n |
\nbool()<\/td>\n | bytearray()<\/td>\n | callable()<\/td>\n | chr()<\/td>\n | classmethod()<\/td>\n<\/tr>\n |
\ncmp()<\/td>\n | compile() <\/td>\n | complex()<\/td>\n | delattr()<\/td>\n | dict()<\/td>\n<\/tr>\n |
\ndir()<\/td>\n | divmod()<\/td>\n | enumerate() <\/td>\n | eval()<\/td>\n | execfile()<\/td>\n<\/tr>\n |
\nfile()<\/td>\n | filter()<\/td>\n | float() <\/td>\n | format()<\/td>\n | frozenset()<\/td>\n<\/tr>\n |
\ngetattr()<\/td>\n | globals()<\/td>\n | hasattr()<\/td>\n | hash()<\/td>\n | help()<\/td>\n<\/tr>\n |
\nhex()<\/td>\n | id()<\/td>\n | input()<\/td>\n | int() <\/td>\n | isinstance()<\/td>\n<\/tr>\n |
\nissubclass()<\/td>\n | iter()<\/td>\n | len()<\/td>\n | list()<\/td>\n | locals()<\/td>\n<\/tr>\n |
\nlong()<\/td>\n | map() <\/td>\n | max()<\/td>\n | memoryview()<\/td>\n | min()<\/td>\n<\/tr>\n |
\nnext() <\/td>\n | object()<\/td>\n | oct() <\/td>\n | open() <\/td>\n | ord()<\/td>\n<\/tr>\n |
\npow()<\/td>\n | print()<\/td>\n | property()<\/td>\n | range()<\/td>\n | raw_input()<\/td>\n<\/tr>\n |
\nreduce()<\/td>\n | reload()<\/td>\n | repr()<\/td>\n | reversed()<\/td>\n | zip()<\/td>\n<\/tr>\n |
\nround() <\/td>\n | set()<\/td>\n | setattr()<\/td>\n | slice()<\/td>\n | sorted()<\/td>\n<\/tr>\n |
\nstaticmethod()<\/td>\n | str()<\/td>\n | sum()<\/td>\n | super()<\/td>\n | tuple()<\/td>\n<\/tr>\n |
\ntype()<\/td>\n | unichr()<\/td>\n | unicode() <\/td>\n | vars()<\/td>\n | xrange()<\/td>\n<\/tr>\n |
\nZip()<\/td>\n | __import__()<\/td>\n | apply()<\/td>\n | buffer()<\/td>\n | coerce()<\/td>\n<\/tr>\n |
\nintern<\/td>\n | <\/td>\n | <\/td>\n | <\/td>\n | <\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n <\/p>\n Python\u4ee3\u7801\u89c4\u8303<\/h2>\n1\u3001\u4ee3\u7801\u884c\u957f\u5ea6<\/h3>\n\n- \u6bcf\u884c\u4ee3\u7801\u5c3d\u91cf\u4e0d\u8d85\u8fc7 80 \u4e2a\u5b57\u7b26\uff0c\u5728\u7279\u6b8a\u60c5\u51b5\u4e0b\u53ef\u4ee5\u7565\u5fae\u8d85\u8fc7 80 \uff0c\u4f46\u6700\u957f\u4e0d\u5f97\u8d85\u8fc7 120\uff1b<\/li>\n<\/ul>\n
<\/p>\n 2\u3001\u5f15\u53f7\u7684\u4f7f\u7528<\/h3>\n\n- \u81ea\u7136\u8bed\u8a00 \u4f7f\u7528\u53cc\u5f15\u53f7 \u201c\u2026\u201d \uff0c\u5982\uff1a\u9519\u8bef\u4fe1\u606f\uff1b\u5f88\u591a\u60c5\u51b5\u8fd8\u662f unicode\uff0c\u4f7f\u7528u\"\u4f60\u597d\u4e16\u754c\"<\/li>\n
- \u673a\u5668\u6807\u8bc6 \u4f7f\u7528\u5355\u5f15\u53f7 \u2018\u2026\u2019 \uff0c\u5982\uff1adict \u91cc\u7684 key<\/li>\n
- \u6b63\u5219\u8868\u8fbe\u5f0f\u4f7f\u7528\u539f\u751f\u7684\u53cc\u5f15\u53f7 r\"\u2026\"<\/li>\n
- \u6587\u6863\u5b57\u7b26\u4e32 (docstring) \u4f7f\u7528\u4e09\u4e2a\u53cc\u5f15\u53f7\"\"\"\u6587\u6863\u5b57\u7b26\u4e32\"\"\"<\/li>\n<\/ul>\n
<\/p>\n 3\u3001\u7a7a\u884c\u7684\u4f7f\u7528<\/h3>\n1\uff09\u6a21\u5757\u4e2d\uff0c\u51fd\u6570\uff0c\u7c7b\u5b9a\u4e49\u4e4b\u95f4\uff0c\u7a7a2\u884c<\/h4>\ndef fun1():\n pass\n\n\ndef fun2():\n pass\n\n\nclass MyClass:\n pass\n<\/code><\/pre>\n <\/p>\n 2\uff09\u7c7b\u6210\u5458\u51fd\u6570\u4e4b\u95f4\uff0c\u7a7a1\u884c <\/h4>\ndef __init__(self):\n pass\n\ndef hello(self):\n pass<\/code><\/pre>\n <\/p>\n 3\uff09\u5728\u4e8c\u5143\u8fd0\u7b97\u7b26\u4e24\u8fb9\uff0c\u5404\u7a7a\u4e00\u683c <\/strong>[=,-,+=,==,>,in,is not, and]<\/h4>\n
|