Skip to content

VS Code 配置Python 与使用Turtle库练习 #2

@iamhtml

Description

@iamhtml
  1. 安装Python3
  2. 安装Visual Studio Code
    未添加安装目录的会出现以下turtle库无法被识别的情况
    import turtle
    piers = turtle.Turtle()
    **turtle**.pensize(4)
    **turtle**.pencolor('red')
    会报错
    3.在VS中选择文件夹后需要在launch.json中加入以下代码,声明Python的安装目录:
    "pythonPath": "E:\Programs\Python\Python37-32\python.exe",
    注意,需要使用双斜杠,不然会报错

image

4.同时,在 settings.json中也会自动添加一个路径
image

5.注意使用的名字就不会报错了
print("hello word22223333")
import turtle
piers = turtle.Turtle()

piers.pensize(4)
piers.pencolor('red')

piers.forward(100)
piers.right(90)
piers.forward(100)
piers.right(90)
piers.forward(100)
piers.right(90)
piers.forward(100)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions