Pycharm的简单配置和使用

外观

Ctrl+滚轮改变字体大小:file -> Setting ->Editor-〉General -> Mouse

字体、颜色:file->settings->Editor

主题:file->settings->Editor->appearance->theme

注释颜色:File-->Settings-->Editor-->Color&Fonts-->LanguageDefaults-->Linecomment

工程和脚本

  • 新建项目(Flie—New Project)时,将inherit global site-packages选项勾选上,否则pycharm每次新建项目都要重新安装第三方库。(建议每次安装第三方库时,都使用pip命令进行安装,这样就免得每次新建项目后都去选择解析器了。这种情况下,第三方库是全局可用的。)
  • 写脚本:新建工程,右击目录,新建python文件。
  • 配置脚本模板:file->settings->Editor->file and code template->python script,在框中添加如下脚本:
#!/usr/bin/env python 
# -*- coding:utf-8 -*-
  • 运行:第一次运行右击脚本run,将脚本切换后再使用右上绿三角run。

  • 第三方包安装:终端pip install pacakge(推荐该方法,系统终端和pycharm终端都可);
    或者:File–>Settings–>Project–>Project Interpreter,点击右侧的+号,进入搜索界面,寻找所需的包,然后点击安装。若不能安装成功,多数是因为网络被限制,需要在Manage Repositories中修改数据来源,默认的是https://pypi.python.org/simple,可将其替换为国内的pip镜像:
    清华:https://pypi.tuna.tsinghua.edu.cn/simple
    阿里:http://mirrors.aliyun.com/pypi/simple/
    豆瓣:http://pypi.douban.com/simple/
    华中理工大学:http://pypi.hustunique.com/
    山东理工大学:http://pypi.sdutlinux.org/
    中国科学技术大学:http://pypi.mirrors.ustc.edu.cn/
    另一种方法就是在命令行下安装轮子(*.whl)文件,如pip install numpy.whl

  • 启动Jupyter notebook:先安装,再File——>new——>Jupyter notebook(新版的Pycharm只有专业版才有);或在终端输入:jupyter notebook

常用快捷键

  • ctrl + D:复制当前行  
  • ctrl + y:删除当前行  
  • shift + Enter:快速换行  
  • ctrl + [:跳到代码开头
  • ctrl + ]:跳到代码结尾
  • ctrl + /: 注释(选中多行后批量注释/取消注释)
  • tab: 缩进当前行(选中多行后批量缩进)  
  • shift + tab: 取消缩进(选中后可以批量取消缩进)  
  • ctrl + f:查找(全局加shift)  
  • ctrl + r:替换(全局加shift)  
  • shift + F10:运行
  • shift + F9:调试
  • F8: 单步调试(一行一行走,我的笔记本无效)
  • Ctrl + F8 : 在当前行加上断点/断点开关
  • Ctrl + N : 快速查找文件

自定义快捷键:file——>setting——>Keymap

单行或分块运行

  • 单行:alt + shift + e运行光标所在行;
  • 分块:选中块代码,再alt + shift + e;或在分块空白行添加#%%,再设置Use scientific mode,但不建议这种,不用时要改回来。

Ref: https://www.jianshu.com/p/883f8343c7dbhttps://blog.csdn.net/TyuansushiT/article/details/81836732
https://blog.csdn.net/qq_40130759/article/details/79421242
https://www.cnblogs.com/sui776265233/p/10200809.html

posted @ 2020-02-14 16:20  生物信息与育种  阅读(840)  评论(0编辑  收藏  举报