Python学习笔记#1:Python + VS Code

目录

  • 前言
  • 下载安装
  • 虚拟环境
  • PIP
    • 换源
  • 代码格式化
    • yapf


前言

对于PYTHON开发,个人使用过PyCharm,Eclipse,如今发现VSCode也非常好用,特此记录如下。

下载安装

  1. VSCode下载安装
    https://code.visualstudio.com

  2. Python下载安装
    https://www.python.org/downloads/

  3. Python新手指引
    https://code.visualstudio.com/docs/python/python-tutorial

虚拟环境

py -3 -m venv .venv
.venv\scripts\activate

如果报错
"Activate.ps1 is not digitally signed. You cannot run this script on the current system."
则执行

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process

PIP

# 进入pip所在的环境
.venv/Scripts/
cd .venv
cd Scripts

# 升级
pip install --upgrade pip

# 安装
pip install xxxxx

换源

官网如果下载太慢,可使用其他源:

其它镜像 地址
阿里云 http://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣(douban) http://pypi.douban.com/simple/
清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/
pip install numpy -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com

代码格式化

使用自动格式化工具,让代码更美观

yapf

vscode的settings.json做如下修改,输入想要的字符数:

{
     
    "python.formatting.provider": "yapf",
    "python.formatting.yapfArgs": ["--style", "{column_limit: 79}"],
}

你可能感兴趣的:(python学习笔记)