当前位置:网站首页>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
边栏推荐
- 混淆矩阵(Confusion Matrix)
- IT冷知识(更新ing~)
- Solutions of ordinary differential equations (2) examples
- AdaBoost use
- 容易混淆的基本概念 成员变量 局部变量 全局变量
- Mengxin summary of LIS (longest ascending subsequence) topics
- EA introduction notes
- Golang foundation - the time data inserted by golang into MySQL is inconsistent with the local time
- [code practice] [stereo matching series] Classic ad census: (4) cross domain cost aggregation
- scipy.misc.imread()
猜你喜欢
[daiy4] copy of JZ35 complex linked list
Halcon snap, get the area and position of coins
Install the CPU version of tensorflow+cuda+cudnn (ultra detailed)
Redis implements a high-performance full-text search engine -- redisearch
AUTOSAR从入门到精通100讲(103)-dbc文件的格式以及创建详解
Rebuild my 3D world [open source] [serialization-2]
Confusing basic concepts member variables local variables global variables
Rebuild my 3D world [open source] [serialization-3] [comparison between colmap and openmvg]
2020 "Lenovo Cup" National College programming online Invitational Competition and the third Shanghai University of technology programming competition
It cold knowledge (updating ing~)
随机推荐
ABC#237 C
Meta标签详解
Typescript hands-on tutorial, easy to understand
C [essential skills] use of configurationmanager class (use of file app.config)
c#比较两张图像的差异
2020 "Lenovo Cup" National College programming online Invitational Competition and the third Shanghai University of technology programming competition
ROS learning 1- create workspaces and function packs
【日常训练--腾讯精选50】557. 反转字符串中的单词 III
Halcon Chinese character recognition
Introduction Guide to stereo vision (1): coordinate system and camera parameters
Solution to the problem of the 10th Programming Competition (synchronized competition) of Harbin University of technology "Colin Minglun Cup"
[beauty of algebra] singular value decomposition (SVD) and its application to linear least squares solution ax=b
Codeforces round 684 (Div. 2) e - green shopping (line segment tree)
3D reconstruction open source code summary [keep updated]
[daiy4] jz32 print binary tree from top to bottom
520 diamond Championship 7-4 7-7 solution
Task failed task_ 1641530057069_ 0002_ m_ 000000
TF coordinate transformation of common components of ros-9 ROS
容易混淆的基本概念 成员变量 局部变量 全局变量
IT冷知识(更新ing~)