首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往
您找到你想要的搜索结果了吗?
是的
没有找到

python获取当前目录路径和上级路径

在使用python的时候总会遇到路径切换的使用情况,如想从文件夹test下的test.py调用data文件夹下的data.txt文件: . └── folder ├── data │...└── data.txt └── test └── test.py 一种方法可以在data文件下加入__init__.py 然后在test.py import data 就可以调用...data.txt文件; 另一种方法可以借助python os模块的方法对目录结构进行操作,下面就说一下这种方式的使用: import os print '***获取当前目录***' print os.getcwd...print '***获取上上级目录***' print os.path.abspath(os.path.join(os.getcwd(), "../.."))...输出结果为: ***获取当前目录*** /workspace/demo/folder/test /workspace/demo/folder/test ***获取上级目录*** /workspace/

9K10

JS获取当前网址信息

通过window.location对象获取对应的属性 1、设置或获取对象指定的文件名或路径(pathname) window.location.pathname 2、设置或获取整个 URL 为字符串(href...) window.kk 3、设置或获取与 URL 关联的端口号码(port) window.location.port 4、设置或获取 URL 的协议部分(protocol) window.location.protocol...设置或获取 href 属性在井号“#”后面的分段(hash) window.location.hash 设置或获取 location 或 URL 的 hostname 和 port 号码(host)...(url.lastIndexOf('=')+1, url.length); 用来得到当前网页的域名 document.domain 注意: 1、获取过后直接使用substring方法截取我们需要的信息。...2、通过正则表达式准确的获取我们需要的参数。

13.7K30

获取当前jar包路径_java获取jar文件

一、获取可执行jar包所在目录 (1)方法一:使用 System.getProperty("java.class.path") 获取classpath的路径,若没有其他依赖,在cmd下运行该可执行jar...代码如下: /** * 方法一:获取当前可执行jar包所在目录 */ String filePath = System.getProperty("java.class.path"); String pathSplit...filePath.substring(0,filePath.indexOf(pathSplit)); }else if (filePath.endsWith(".jar")) { //截取路径的...ClassName.class.getProtectionDomain().getCodeSource().getLocation().getPath() 但是这种方法不支持中文,需要使用以下代码方法,进行转换 /** * 方法二:获取当前可执行...System.out.println("jar包所在目录:"+filePath); 二、获取当前JVM运行目录 使用: System.getProperty("user.dir") 三、获取jar包内的资源文件

6.5K20

前端如何获取当前时间_js 获取年份

前端js获取当前时间的方法: var time = new Date(); time.getYear(); //获取当前年份 time.getFullYear(); //获取完整的年份(4位,1970...time.getMonth(); //获取当前月份(0-11,0代表1月) time.getDate(); //获取当前日(1-31) time.getDay(); //获取当前星期X(0-6,0代表星期天...) time.getTime(); //获取当前时间(从1970.1.1开始的毫秒数) time.getHours(); //获取当前小时数(0-23) time.getMinutes(); //...获取当前分钟数(0-59) time.getSeconds(); //获取当前秒数(0-59) time.getMilliseconds(); //获取当前毫秒数(0-999) time.toLocaleDateString...(); //获取当前日期 var mytime=time.toLocaleTimeString(); //获取当前时间 time.toLocaleString( ); //获取日期与时间 为了让大家有一个更感官的了解

33.8K20
领券