七、连 Pycharm 都不知道怎么用,学什么 Python
@Author : Runsen
我决定把去年写的Python文章整理一个专栏,垃圾的就直接删除,将多篇博文整理成一篇。
工欲善其事必先利其器,Pycharm 是最受欢迎的Python开发工具,它提供的功能非常强大,我尽量把自己用的都写写吧
1、设置Python 解释器
在任何项目,第一步就是设置Python 解释器,就是那个Python.exe
在File->Setting->Projec: xxx 下找到 Project Interpreter。然后修改为你需要的 Python 解释器。注意这个地方一定要注意的是:在选择 Python 解释器的时候,一定要选择到 python.exe 这个文件,而不是 python 的安装文件夹。

咋RunsenPycharm中设置了有anacodna的 python.exe ,有远程的python.exe,有直接下载的python.exe

本地和anaconda不说了,太他妈简单了,就说如何远程虚拟机吧,连接Docker,可能小白都不知道什么是Docker,以后在说吧
1.1 远程配置
Pycharm设置远程应该是使用Django项目的时候,

其实很简单,我就拿我的Centos7 ip是192.168.9290

用户名的密码


然后就是配置中两个东西





出现了Deployment就说明OK了。

2、调整字体及其大小
2.1 调整编辑器字体及其大小
所有的位置都是在Settings中,具体哪里看图

2.2 调整控制台的字体及其大小

3、设置编码

4、修改文件背景颜色

5、设置Git 和Github
5.1 配置git
Git的位置

5.2 配置github

现在就可以上传代码到github

上次代码到Github的Commit



5.3 下载仓库内容


6 、新建.py文件时默认添加信息
这是去年的博客
对于pycharm我们每次新建Python文件时需要加的注释信息和作者时间等信息可以使用模板的方式,这样每次新建文件之后就默认添加比较方便。
1、点击pycharm的右上角的file出现如下图点击settings:

2、接着就是找到如下图的地方:

3、在里面加上想要创建文件之后就默认添加的内容,下面是编辑内容的具体格式:
预定义的变量要扩展为格式为$ {<variable_name>}的相应值。
可用的预定义文件模板变量为:
$ {PROJECT_NAME} - 当前项目的名称。
$ {NAME} - 在文件创建过程中在“新建文件”对话框中指定的新文件的名称。
$ {USER} - 当前用户的登录名。
$ {DATE} - 当前的系统日期。
$ {TIME} - 当前系统时间。
$ {YEAR} - 今年。
$ {MONTH} - 当月。
$ {DAY} - 当月的当天。
$ {HOUR} - 目前的小时。
$ {MINUTE} - 当前分钟。
$ {PRODUCT_NAME} - 将在其中创建文件的IDE的名称。
$ {MONTHNAMESHORT} - 月份名称的前3个字母。 示例:1月,2月等
$ {MONTHNAMEFULL} - 一个月的全名。 示例:1月,2月等

7、恢复代码
如果误删了代码,不要怕


8、代码换行
写的代码多了,可以Soft--Wrap自动换行

9、Reformat Code
写的代码不够好看,直接Reformat

10、连接数据库


Host: 远程ip 若是连接本地MySQL 直接写localhost即可
Database: 填写数据库名称,不写默认连接之后,可以查看当前用户权限下的所有数据库
User: MySQL用户名
Password: MySQL密码
注意: 首次连接需要下载驱动,点击左下角的Download下载
下载完毕后,点击test connection ,测试连接 成功显示Successful Details



11、 Debug



前面的信息就可以显示出来
12、PyCharm 常用快捷键
熟悉每个编辑器的快捷键,能大大提高你的工作效率。


总结
这里介绍了Pycharm的日常使用,关键就是不断地练习。
接下来下面开始Python编程入门
>本文已收录 GitHub,传送门~ ,里面更有大厂面试完整考点,欢迎 Star。
<br>
<br>
版权声明: 本文为 InfoQ 作者【刘润森】的原创文章。
原文链接:【http://xie.infoq.cn/article/9ab13e4e8d76bb35a81251006】。未经作者许可,禁止转载。
评论