首页文章正文

Python获取当前路径,bat获取当前目录路径

python读取路径 2023-05-25 22:45 653 墨鱼
python读取路径

Python获取当前路径,bat获取当前目录路径

Python获取当前路径,bat获取当前目录路径

1.Getthecurrentpath1.Usesys.argv[0]importsysprintsys.argv[0]#Output#localpath2.osmoduleimportosprintos.getcwd()#Getthecurrentworkingdirectorypathprintos.path.abspath2.Method1toobtainthecurrentpathusingPython1.Method1:importoscurrent_path=os.getcwd()print("Thecurrentpathis:, current_path)以上代码演示使用Python的sos

python获取当前路径和上一层路径

sys.path[0]获取文件的当前工作目录路径(绝对路径)getabsolutepython-获取当前文件路径getcwd获取当前工作路径,即脚本运行的地方,而不是脚本本身存在的地方python-获取当前文件路径1、os.getcwd():os.getcwd()不需要

python获取当前路径的文件夹

os.path.split(os.path.realpath(__file__))[0]"D:\python_test",thedirectorywhere__file__islocated是目录wheretest_path.pyislocated正确获取当前路径:__file__是当前执行文件#Getthecurrentfile(__file__)))#Gettheabsolutepathofthefolderwherethecurrentfileislocated#Readtheparametertxtfileasstrdir=os.path.dirname(操作系统 .path.abspath(__file__))+'\\parameter_setting\\control

python获取当前路径的方法

获取当前工作路径。 这是绝对路径。 _file__获取模块所在的路径,可能是相对路径。 如果显示执行Python,则获取绝对路径。 如果直接按照相对路径执行脚本./pyws/path_demo.py,就会得到相对路径。 python获取当前路径的几种方法absolutepath1,os.pathmethod#-*-coding:utf-8-*-#!/usr/bin/pythonimportosimportsyscurrent_directory=os.path.dirname(os

后台-插件-广告管理-内容页尾部广告(手机)

标签: bat获取当前目录路径

发表评论

评论列表

黑豹加速器 Copyright @ 2011-2022 All Rights Reserved. 版权所有 备案号:京ICP1234567-2号