vscode配置python环境并解决输出中文乱码问题

  • 安装python最新版本,把安装路径添加到环境变量中。
  • 安装vscode,在拓展商店安装python插件和 code runner 插件
    vscode配置python环境并解决输出中文乱码问题_第1张图片
    在这里插入图片描述
  • 在vscode的settings.json用户区中添加以下内容,把里面的python路径改为你的.
"code-runner.executorMap": {
     
        "javascript": "node",
        "java": "cd $dir && javac $fileName && java $fileNameWithoutExt",
        "c": "cd $dir && gcc $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
        "cpp": "cd $dir && g++ $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
        "objective-c": "cd $dir && gcc -framework Cocoa $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
        "php": "php",
        "python": "set PYTHONIOENCODING=utf8 && C:\\Python\\Python37\\python.exe",
        "perl": "perl",
        "perl6": "perl6",
        "ruby": "ruby",
        "go": "go run",
        "lua": "lua",
        "groovy": "groovy",
        "powershell": "powershell -ExecutionPolicy ByPass -File",
        "bat": "cmd /c",
        "shellscript": "bash",
        "fsharp": "fsi",
        "csharp": "scriptcs",
        "vbscript": "cscript //Nologo",
        "typescript": "ts-node",
        "coffeescript": "coffee",
        "scala": "scala",
        "swift": "swift",
        "julia": "julia",
        "crystal": "crystal",
        "ocaml": "ocaml",
        "r": "Rscript",
        "applescript": "osascript",
        "clojure": "lein exec",
        "haxe": "haxe --cwd $dirWithoutTrailingSlash --run $fileNameWithoutExt",
        "rust": "cd $dir && rustc $fileName && $dir$fileNameWithoutExt",
        "racket": "racket",
        "ahk": "autohotkey",
        "autoit": "autoit3",
        "dart": "dart",
        "pascal": "cd $dir && fpc $fileName && $dir$fileNameWithoutExt",
        "d": "cd $dir && dmd $fileName && $dir$fileNameWithoutExt",
        "haskell": "runhaskell",
        "nim": "nim compile --verbosity:0 --hints:off --run",
        "lisp": "sbcl --script",
        "kit": "kitc --run"
    },

vscode配置python环境并解决输出中文乱码问题_第2张图片
这样就不会输出中文乱码了,输出如图所示:
vscode配置python环境并解决输出中文乱码问题_第3张图片
相关推荐:
vscode配置c++环境及解决中文输出乱码问题
vscode配置js环境

你可能感兴趣的:(vscode)