For an example, I have my folder path as “/content/data/a/b/c/d/” How can I extract the “b” from this path?
Advertisement
Answer
If “b” never moves
JavaScript
x
3
1
file_path = "/content/data/a/b/c/d/"
2
file_path.split('/')[4]
3
If it does move
JavaScript
1
3
1
file_path = "/content/data/a/b/c/d/"
2
file_path[file_path.index("b")]
3