3 Star 1 Fork 2

alvin/PythonBasics

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

PythonBasics

Markdown语法学习

https://www.runoob.com/markdown/md-title.html

介绍

Python程序设计基础课程代码。
专业版pyCharm:默认支持python(.py)和jupyter(.ipynb)两种代码。

软件架构

软件架构说明

推荐阅读

推荐阅读:官网、软件、API

推荐阅读:技术篇

  • Python,for variable names,function names,method names,and module or package(i.e file) names
  • 即包名、模块名、方法名和普通变量名等情况,则是推荐用蛇形命名(lower_case_with_underscores)
  • do-while 能够解决的几个问题要么在 Python 中并不存在(宏定义、汇编指令),要么就是已经有更为合适而低成本的实现(跳转控制)
  • Python 模块(Module),是一个 Python 文件,以 .py 结尾,包含了 Python 对象定义和Python语句。
  • 模块能定义函数,类和变量,模块也能包含可执行的代码。
  • 导入模块的方式:
  • import 模块名
 - from 模块名 import 功能名
 - from 模块名 import *
 - import 模块名 as 别名
 - from 模块名 import 功能名 as 别名

快捷键

在 Jupyter Notebook 中最常用的快捷键:

  • Shift + Enter:运行当前单元格,并跳到下一个单元格。
  • Ctrl + Enter:只运行当前单元格。
  • Alt + Enter:执行当前单元格,并且会新建一个单元格。
  • Alt + Shift +B:在当前选中的单元格下方新建一个空单元格(不运行当前单元格)
  • (ESC进入到命令行模式)按Y/M对应切换到 Code/Markdown 模式。
  • 在网页端,按tab可以补全代码。ESC后按H会弹出jupyter支持的各种快捷键操作,大家自己试一试。

PyCharm快捷键(文件-设置-按键映射-编辑器操作)

优先掌握加粗的快捷键
  1. 基本编辑快捷键
  • Ctrl + Space:基本的代码完成(类、方法、属性)
  • Ctrl + Alt + Space:快速导入任意类
  • Ctrl + Shift + Enter:语句完成
  • Ctrl + P:参数信息(在方法中调用参数)
  • Ctrl + Q:快速查看文档
  • F1:外部文档
  • Shift + F1:外部文档,进入web文档主页
  • Ctrl + Shift + Z 或者 Ctrl + Y:撤销上一步操作 / 重做
  • Ctrl + 鼠标左键:悬浮/单击鼠标左键,显示简介/进入代码定义
  • Ctrl + F1:显示错误描述或警告信息
  • Alt + Insert:自动生成代码
  • Ctrl + O:重新方法
  • Ctrl + Alt + T:选中
  • Ctrl + /:行注释/取消行注释
  • Ctrl + Shift + /:块注释
  • Ctrl + W:选中增加的代码块
  • Ctrl + Shift + W:回到之前状态
  • Alt + Enter:快速修正
  • Ctrl + Alt + L:代码格式化
  • Ctrl + Alt + O:优化导入
  • Ctrl + Alt + I:自动缩进
  • Tab / Shift + Tab:缩进、不缩进当前行
  • Ctrl+X/Shift+Delete:剪切当前行或选定的代码块到剪贴板
  • Ctrl+C/Ctrl+Insert:复制当前行或选定的代码块到剪贴板
  • Ctrl+V/Shift+Insert:从剪贴板粘贴
  • Ctrl + Shift + V:从最近的缓冲区粘贴
  • Ctrl + D:复制选定的区域或行
  • Ctrl + Y:删除选定的行
  • Ctrl + Shift + J:添加智能线
  • Ctrl + Enter:智能线切割
  • Shift + Enter:另起一行
  • Ctrl + Shift + U:在选定的区域或代码块间切换
  • Ctrl + Delete:删除到字符结束
  • Ctrl + Backspace:删除到字符开始
  • Ctrl + Numpad+/-:展开/折叠代码块(当前位置的:函数,注释等)
  • Ctrl + shift + Numpad+/-:展开/折叠所有代码块
  • Ctrl + F4:关闭运行的选项卡
  1. 查找/替换快捷键
  • F3:下一个
  • Shift + F3:前一个
  • Ctrl + R:替换
  • Ctrl + Shift + F 或者连续2次敲击shift:全局查找{可以在整个项目中查找某个字符串什么的,如查找某个函数名字符串看之前是怎么使用这个函数的}
  • Ctrl + Shift + R:全局替换
  1. 运行快捷键
  • Alt + Shift + F10:运行模式配置
  • Alt + Shift + F9:调试模式配置
  • Shift + F10:运行
  • Shift + F9:调试
  • Ctrl + Shift + F10:运行编辑器配置
  • Ctrl + Alt + R:运行manage.py任务
  1. 调试快捷键
  • F8:跳过
  • F7:进入
  • Shift + F8:退出
  • Alt + F9:运行游标
  • Alt + F8:验证表达式
  • Ctrl + Alt + F8:快速验证表达式
  • F9:恢复程序
  • Ctrl + F8:断点开关
  • Ctrl + Shift + F8:查看断点
  1. 导航快捷键
  • Ctrl + N:跳转到类
  • Ctrl + Shift + N:跳转到符号
  • Alt + Right/Left:跳转到下一个、前一个编辑的选项卡(代码文件)
  • Alt + Up/Down:跳转到上一个、下一个方法
  • F12:回到先前的工具窗口
  • Esc:从工具窗口回到编辑窗口
  • Shift + Esc:隐藏运行的、最近运行的窗口
  • Ctrl + Shift + F4:关闭主动运行的选项卡
  • Ctrl + G:查看当前行号、字符号
  • Ctrl + E:当前文件弹出,打开最近使用的文件列表
  • Ctrl+Alt+Left/Right:后退、前进
  • Ctrl+Shift+Backspace:导航到最近编辑区域 {差不多就是返回上次编辑的位置}
  • Alt + F1:查找当前文件或标识
  • Ctrl + B / Ctrl + Click:跳转到声明
  • Ctrl + Alt + B:跳转到实现
  • Ctrl + Shift + I:查看快速定义
  • Ctrl + Shift + B:跳转到类型声明
  • Ctrl + U:跳转到父方法、父类
  • Ctrl + ]/[:跳转到代码块结束、开始
  • Ctrl + F12:弹出文件结构
  • Ctrl + H:类型层次结构
  • Ctrl + Shift + H:方法层次结构
  • Ctrl + Alt + H:调用层次结构
  • F2 / Shift + F2:下一条、前一条高亮的错误
  • F4 / Ctrl + Enter:编辑资源、查看资源
  • Alt + Home:显示导航条
  • F11:书签开关
  • Ctrl + Shift + F11:书签助记开关
  • Ctrl + #[0-9]:跳转到标识的书签
  • Shift + F11:显示书签
  1. 搜索相关快捷键
  • Alt + F7 / Ctrl + F7:文件中查询用法
  • Ctrl + Shift + F7:文件中用法高亮显示
  • Ctrl + Alt + F7:显示用法
  1. 重构快捷键
  • F5:复制
  • F6:剪切
  • Alt + Delete:安全删除
  • Shift + F6:重命名
  • Ctrl + F6:更改签名
  • Ctrl + Alt + N:内联
  • Ctrl + Alt + M:提取方法
  • Ctrl + Alt + V:提取属性
  • Ctrl + Alt + F:提取字段
  • Ctrl + Alt + C:提取常量
  • Ctrl + Alt + P:提取参数
  1. 控制VCS/Local History快捷键
  • Ctrl + K:提交项目
  • Ctrl + T:更新项目
  • Alt + Shift + C:查看最近的变化
  • Alt + BackQuote(’):VCS快速弹出
  1. 模版快捷键
  • Ctrl + Alt + J:当前行使用模版
  • Ctrl + J:插入模版
  1. 基本快捷键
  • Alt + #[0-9]:打开相应的工具窗口
    • Alt + 7 打开文件结构(显示类、方法列表信息)
  • Ctrl + Alt + Y:同步
  • Ctrl + Shift + F12:最大化编辑开关
  • Alt + Shift + F:添加到最喜欢
  • Alt + Shift + I:根据配置检查当前文件 正在为您搜索:继续
  • Ctrl + Alt + S:打开设置对话框
  • Ctrl + Shift + A:查找动作
  • Ctrl + Tab:在窗口间进行切换
  • Alt + Insert:生成代码
  • Ctrl + /:注释(// 或者 /.../ )
  • Ctrl + Shift + /:添加/删除快注释(/**...*/)
  • Ctrl + W:递进式取消选择代码块
  • Ctrl + Shift + W:递进式选择代码块
  • Alt + Q:精确定位到光标所在的代码块,然后再次按返回先前的位置
  • Ctrl + Shift + ]/[:选中当前代码块的闭合部分,比如一对大括号中的所有内容
  • Ctrl + F4:关闭当前编辑页签
  • Ctrl + Shift + U:转换选中的文本(大写、小写、切换大小写)

插件安装教程(一般都是直接在插件市场搜索安装相应的插件然后重启)

  1. Chinese(Simplified) Language Pack / 中文语言包 (软件汉化)
  2. Rainbow Brackets 括号的嵌套很容易混淆。这个插件可以帮助你更好地追踪代码块,不同层级的括号用不同的颜色用以区分,让你更快地理解代码结构。
  3. Key Promoter X 这个插件提供了快捷键的提示与帮助,学习使用PyCharm中的快捷键会大大提升您的工作效率。
  4. CodeGlance 这个插件可以在编辑器右侧添加一个代码缩略图,方便快速浏览代码。再也不用鼠标滚动到全部到文件底部了,这个插件给你提供了一个效率提升的小工具。
  5. Gitee/Github 平台上有很多开源代码可供学习。可作为代码云端管理,可以用来取代以前的svn。Gitee是Github的国内平替。
  6. aiXcoder Code Completer 代码补全工具,可以自动根据输入的文本内容提供相关代码选项,从而提高编程效率。它通常与集成开发环境(IDE)结合使用,例如 VS Code、PyCharm 等。通过 aiXcoder Code Completer,用户可以在编写代码时实时查看和选择可能的最佳代码选项,从而减少重复输入和错误率,提高开发效率。
  7. CodeGeeX插件 AI辅助编码
  1. python.exe -m pip install --upgrade pip

jieba

  1. jieba官网
  2. jieba Github
  3. jieba Gitee
  4. 安装指令:pip install jieba

Wordcloud云图

  1. 安装Wordcloud库: 5.1 方法1:在Windows命令提示符窗口中,输入命令行命令“pip install wordcloud”,以安装Wordcloud库。注意,使用该方法需要本地计算机安装了Microsoft Visual C++ 14.0编译器,否则安装会失败,失败参考
    5.2 wordcloud本地安装,whl文件下载地址

NLTK(拓展内容)

  1. NLTK官网
  2. NLTK模型数据
  3. NLTK安装nltk:pip install nltk

特技

  1. 使用 Readme_XXX.md 来支持不同的语言,例如 Readme_en.md, Readme_zh.md
  2. Gitee 官方博客 blog.gitee.com
  3. 你可以 https://gitee.com/explore 这个地址来了解 Gitee 上的优秀开源项目
  4. GVP 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
  5. Gitee 官方提供的使用手册 https://gitee.com/help
  6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 https://gitee.com/gitee-stars/
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

简介

Python程序设计基础课程代码 展开 收起
README
Apache-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/alvin_pc/python-basics.git
git@gitee.com:alvin_pc/python-basics.git
alvin_pc
python-basics
PythonBasics
master

搜索帮助