当前位置:网站首页>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
边栏推荐
- C [essential skills] use of configurationmanager class (use of file app.config)
- C#图像差异对比:图像相减(指针法、高速)
- Codeforces round 684 (Div. 2) e - green shopping (line segment tree)
- Business modeling of software model | overview
- Codeforces Round #648 (Div. 2) D. Solve The Maze
- Rebuild my 3D world [open source] [serialization-1]
- Summary of "reversal" problem in challenge Programming Competition
- JS asynchronous error handling
- Adaboost使用
- Typescript hands-on tutorial, easy to understand
猜你喜欢
Codeworks round 639 (Div. 2) cute new problem solution
[technical school] spatial accuracy of binocular stereo vision system: accurate quantitative analysis
Install the CPU version of tensorflow+cuda+cudnn (ultra detailed)
Ros- learn basic knowledge of 0 ROS - nodes, running ROS nodes, topics, services, etc
C [essential skills] use of configurationmanager class (use of file app.config)
C# LINQ源码分析之Count
生成对抗网络
RT-Thread内核快速入门,内核实现与应用开发学习随笔记
Halcon blob analysis (ball.hdev)
TF coordinate transformation of common components of ros-9 ROS
随机推荐
Basic number theory - fast power
Golang foundation -- map, array and slice store different types of data
OpenFeign
C#图像差异对比:图像相减(指针法、高速)
[code practice] [stereo matching series] Classic ad census: (5) scan line optimization
MPSoC QSPI flash upgrade method
Basic number theory -- Euler function
Ros-11 common visualization tools
【日常訓練--騰訊精選50】557. 反轉字符串中的單詞 III
uni-app 实现全局变量
.NET服务治理之限流中间件-FireflySoft.RateLimit
[Niuke brush questions day4] jz55 depth of binary tree
嗨 FUN 一夏,与 StarRocks 一起玩转 SQL Planner!
我从技术到产品经理的几点体会
Numpy pit: after the addition of dimension (n, 1) and dimension (n,) array, the dimension becomes (n, n)
【日常训练】1200. 最小绝对差
Ros- learn basic knowledge of 0 ROS - nodes, running ROS nodes, topics, services, etc
[technical school] spatial accuracy of binocular stereo vision system: accurate quantitative analysis
Halcon clolor_ pieces. Hedv: classifier_ Color recognition
Configuration and startup of kubedm series-02-kubelet