当前位置:网站首页>fs. Path module
fs. Path module
2022-07-05 08:57:00 【Yang Xun】
When using relative paths to read or write files ,node In execution js The file will automatically be node Splicing the current running path of the command with the relative path of reading or writing will lead to reading or writing failure. At this time, it is necessary __dirname To splice paths ,__dirname Represents the absolute path of the current file ,
When using path splicing, if the path contains ./ Then that point will also be node Identifying as a path execution will lead to read or write failure , So we need to use path.join(__dirname,’./ route ’) To splice paths , This method will automatically ignore ./ or …/ In the point , If it is …/ Will automatically offset the previous layer of path, such as path.join(__dirname,’/a’,’/b/c’,’…/d’,’/e’), This path will eventually be spliced into ’\a\b\d\e’
path.basename(‘ Spliced path ’,‘ Suffix to delete ’)
As shown in the figure below :
Get the suffix of the file
边栏推荐
- Dynamic dimensions required for input: input, but no shapes were provided. Automatically overriding
- Basic number theory - fast power
- Rebuild my 3D world [open source] [serialization-3] [comparison between colmap and openmvg]
- C#【必备技能篇】ConfigurationManager 类的使用(文件App.config的使用)
- kubeadm系列-00-overview
- [code practice] [stereo matching series] Classic ad census: (5) scan line optimization
- Halcon snap, get the area and position of coins
- Chris LATTNER, the father of llvm: why should we rebuild AI infrastructure software
- Pearson correlation coefficient
- C [essential skills] use of configurationmanager class (use of file app.config)
猜你喜欢
The combination of deep learning model and wet experiment is expected to be used for metabolic flux analysis
资源变现小程序添加折扣充值和折扣影票插件
[Niuke brush questions day4] jz55 depth of binary tree
Add discount recharge and discount shadow ticket plug-ins to the resource realization applet
Introduction Guide to stereo vision (3): Zhang calibration method of camera calibration [ultra detailed and worthy of collection]
Pytorch entry record
3D reconstruction open source code summary [keep updated]
Ros- learn basic knowledge of 0 ROS - nodes, running ROS nodes, topics, services, etc
微信H5公众号获取openid爬坑记
EA introduction notes
随机推荐
容易混淆的基本概念 成员变量 局部变量 全局变量
scipy.misc.imread()
Ros-11 common visualization tools
多元线性回归(梯度下降法)
Tips 1: Web video playback code
优先级队列(堆)
[daiy4] jz32 print binary tree from top to bottom
什么是防火墙?防火墙基础知识讲解
多元线性回归(sklearn法)
LLVM之父Chris Lattner:为什么我们要重建AI基础设施软件
【日常训练--腾讯精选50】557. 反转字符串中的单词 III
[beauty of algebra] solution method of linear equations ax=0
Digital analog 1: linear programming
使用arm Neon操作,提高内存拷贝速度
C#【必备技能篇】ConfigurationManager 类的使用(文件App.config的使用)
One dimensional vector transpose point multiplication np dot
Programming implementation of ROS learning 5-client node
[technical school] spatial accuracy of binocular stereo vision system: accurate quantitative analysis
.NET服务治理之限流中间件-FireflySoft.RateLimit
Dynamic dimensions required for input: input, but no shapes were provided. Automatically overriding