5-2 分離目錄路徑和檔名
輸入檔案目錄路徑和檔名,要求分離成目錄路徑和檔名分別輸出
輸入格式:
例如:輸入
c:\windows\winhelp.exe
輸出格式:
c:\windows (目錄路徑)
winhelp.exe (檔名)
輸入樣例:
/usr/bin/man
輸出樣例:
/usr/bin
man
#include
#include
using
namespace
std;
void filename(const
string & str)
關鍵在於這兩個函式的使用
如果不清楚這兩個函式的使用,就要繞乙個大圈子!
我就被困了好久
後面才發現那麼簡單!
Python基礎之分離檔名和檔案路徑
分離檔名與檔案路徑 import osif name main path e test module log folder path,file name os.path.split path print 需要分離的檔案路徑是 path print n分離後的結果是 print 檔名 file nam...
獲取檔名和檔案路徑
1.問題描述 比如已經知道檔案的路徑是 c dir0 dir1 readme.txt 除了用split 的方式獲取檔名和路徑,有沒有什麼更高效的方式 2.解決辦法 os.path.dirname 路徑 os.path.basename 檔名 import os file path d work te...
DOS命令應用之分離路徑和檔名
dos命令應用之分離路徑和檔名 echo off 獲取某個路徑格式字串中指定節的字串 code by jm 2006 12 11 cmd xp set str c t est abc.txt cd h yes h for f tokens 2 delims i in str do echo i j ...