首页 > 编程语言 >在VS code 中执行python文件查询路径是上级目录的问题

在VS code 中执行python文件查询路径是上级目录的问题

时间:2024-01-14 18:56:45浏览次数:31  
标签:插件 code python 路径 VS 目录

在VS code 中执行python文件查询路径是上级目录的问题

问题描述: 获取当前目录:
import os
print(">> 当前路径:",os.getcwd()) #  >> 当前路径: D:\code\python

输出的是当前目录的父目录。

image

解决方法:

  • python插件设置。
  • run code插件设置。

第一步,python插件
打开设置Python插件的运行,搜索 python.terminal.executeInFileDir 打勾。

参考: https://blog.csdn.net/aoeryule/article/details/127504616

标签:插件,code,python,路径,VS,目录
From: https://www.cnblogs.com/lofly/p/17963982

相关文章

  • python面向对象之类的内置方法
    【引入】Python的Class机制内置了很多特殊的方法来帮助使用者高度定制自己的类这些内置方法都是以双下划线开头和结尾的,会在满足某种条件时自动触发__init__ :初始化类时触发__del__ :删除类时触发__new__ :构造类时触发__str__ :str函数或者print函数触发__repr__ :repr或......
  • python client of influxdb v2
    pythonclienthttps://docs.influxdata.com/influxdb/v2/api-guide/tutorials/python/#authenticate-with-an-influxdb-api-tokenFollowthisstep-by-steptutorialtobuildanInternet-of-Things(IoT)applicationwithInfluxDataclientlibrariesandyourfavorit......
  • [刷题技巧] LeetCode238. 除自身以外数组的乘积
    题目描述思路:前缀/后缀乘积数组构造除自身以外数组的左边前缀乘积构造除自身以外数组的右边后缀乘积然后对应位置相乘方法一:classSolution{publicint[]productExceptSelf(int[]nums){intn=nums.length;//前缀乘积数组:leftProduct[i]表......
  • Python面向对象之反射
    反射【一】什么是反射反射是一种程序可以访问、检测和修改其本身状态或行为的能力。在Python中,反射主要指通过字符串的形式操作对象的属性。【二】Python中的反射通过字符串的形式操作对象相关的属性。python中的一切事物都是对象(都可以使用反射)【三】反射方法class......
  • Codeforces Round 919 (Div. 2)
    CodeforcesRound919(Div.2)A-SatisfyingConstraints#include<bits/stdc++.h>#defineendl'\n'#defineintlonglongusingnamespacestd;constintN=1e6+10;voidsolve(){ intn; intl=-1; intr=1e9+10; cin>>......
  • different python version + venv
    ubuntu系统上安装不同python版本https://www.bandwagonhost.net/7309.html比如安装Python3.7:sudoaptinstallpython3.7或者安装Python3.6:sudoaptinstallpython3.6安装之后,我们就可以使用Python对应版本了,比如看一下Python3.7的具体版本:python3.7-V构造应......
  • [刷题班] LeetCode1480. 一维数组的动态和
    题目描述思路:前缀和前缀和数组(prefixSum)的构造方法一:classSolution{publicint[]runningSum(int[]nums){int[]preSum=newint[nums.length];preSum[0]=nums[0];for(inti=1;i<nums.length;i++){preSum[i]......
  • [刷题班] LeetCode125. 验证回文串
    题目描述思路:左右指针只考虑数字和字母字母的话需要全部转化为小写然后使用左右指针判断是否是回文串方法一:classSolution{publicbooleanisPalindrome(Strings){List<Character>list=newArrayList<>();for(charc:s.toCharArray()){......
  • python二分法查找
    比如要在列表arr中查找xdeff(arr,x):left=0right=len(arr)whileleft<right:mid=(left+right)//2ifmid<x:left=midelifmid>x:right=midelse:returnmid......
  • [刷题班] LeetCode11. 盛最多水的容器
    题目描述思路:左右指针方法一:暴力,超出时间限制模拟所有情况,记录最大的体积值。体积=Math.min(height[i],height[j])*(j-i)classSolution{publicintmaxArea(int[]height){intres=Integer.MIN_VALUE;for(inti=0;i<height.leng......