라벨이 os.path인 게시물 표시

파이썬[Python]: os.path - supports_unicode_filenames 변수

파이썬(Python): os.path 모듈 - supports_unicode_filenames 변수(variable) /// 설명 경로명에 유니코드 문자열을 사용할 수 있으면 True를 반환합니다. ※ 형식 os.path.supports_unicode_filenames /// 예제 1 2 3 4 5 6 7 8 import  os.path   test_path  =  os.getcwd()   # 현재 디렉토리를 반환합니다. print (test_path) # D:\......\Computer_Program\Py\Practice   print (os.path.supports_unicode_filenames)   # True   Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: os.path - splitdrive 함수

파이썬(Python): os.path 모듈 - splitdrive 함수(function) /// 설명 (drive, tail)의 형태로 경로가 분리되어 집니다. drive는 마운트 포인트 이거나 빈 문자열일 수 있습니다. ※ 형식 os.path.splitdrive(path) /// 예제 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 import  os.path   test_path  =  os.getcwd()   # 현재 디렉토리를 반환합니다. print (test_path) # D:\......\Computer_Program\Py\Practice   test_splitdrive  =  os.path.splitdrive(test_path) print (test_splitdrive)   # ('D:', '\\......\\Computer_Program\\Py\\Practice')   test_splitdrive  =  os.path.splitdrive(test_path  +   '/' ) print (test_splitdrive)   # ('D:', '\\......\\Computer_Program\\Py\\Practice/')   test_splitdrive  =  os.path.splitdrive( '' ) print (test_splitdrive)   # ('', '')   Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: os.path - split 함수

파이썬(Python): os.path 모듈 - split 함수(function) /// 설명 (head, tail)의 형태로 경로가 분리되어 집니다. tail은 마지막 경로명이며, head는 그 외 나머지 경로명을 가리킵니다. ※ 형식 os.path.split(path) /// 예제 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 import  os.path   test_path  =  os.getcwd()   # 현재 디렉토리를 반환합니다. print (test_path) # D:\......\Computer_Program\Py\Practice   test_split  =  os.path.split(test_path) print (test_split)   # ('D:\\......\\Computer_Program\\Py', 'Practice')   test_split  =  os.path.split(test_path  +   '/' ) print (test_split)   # ('D:\\......\\Computer_Program\\Py\\Practice', '')   test_split  =  os.path.split( '' ) print (test_split)   # ('', '')   Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: os.path - samefile 함수

파이썬(Python): os.path 모듈 - samefile 함수(function) /// 설명 두 인자의 값이 같은 파일이나 디렉토리를 갖는 다면 True를 반환합니다. 이 함수는 장치번호나 i-node 번호에 의해서 결정되어집니다. ※ 형식 os.path.samefile(path1, path2) /// 예제 1 2 3 4 5 6 7 8 9 import  os.path   test_path  =  os.getcwd()   # 현재 디렉토리를 반환합니다. print (test_path) # D:\......\Computer_Program\Py\Practice   test_samefile  =  os.path.samefile( './' , test_path) print (test_samefile)   # True   Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: os.path - relpath 함수

파이썬(Python): os.path 모듈 - relpath 함수(function) /// 설명 인자 start에서 path에 이르기까지의 상대경로를 반환합니다. ※ 형식 os.path.relpath(path, start=os.curdir) /// 예제 1 2 3 4 5 6 7 8 9 10 11 import  os.path   test_path  =  os.getcwd()   # 현재 디렉토리를 반환합니다. print (test_path) # D:\......\Computer_Program\Py\Practice   test_other  =   'D:\ABCD'   test_relpath  =  os.path.relpath(test_other, start = test_path) print (test_relpath)   # ..\..\..\..\ABCD   Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: os.path - normpath 함수

파이썬(Python): os.path 모듈 - normpath 함수(function) /// 설명 불필요한 구분자를 삭제한 경로명을 반환합니다. A//B, A/B/, A/./B and A/xxx/../B ---> A/B ※ 형식 os.path.normpath(path) /// 예제 1 2 3 4 5 6 7 8 9 10 11 import  os.path   test_path  =  os.getcwd()   # 현재 디렉토리를 반환합니다. print (test_path) # D:\......\Computer_Program\Py\Practice   test_path  =   'D:\......\\\\Computer_Program\.\Py\Practice'   test_normpath  =  os.path.normpath(test_path) print (test_normpath)   # D:\......\computer_program\py\practice   Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: os.path - normcase 함수

파이썬(Python): os.path 모듈 - normcase 함수(function) /// 설명 경로를 일반화된 형태로 표현합니다. 모든 문자는 소문자로 변경되며, forward slash(/)는 backward slash(\)로 변경됩니다. ※ 형식 os.path.normcase(path) /// 예제 1 2 3 4 5 6 7 8 9 import  os.path   test_path  =  os.getcwd()   # 현재 디렉토리를 반환합니다. print (test_path) # D:\......\Computer_Program\Py\Practice   test_normcase  =  os.path.normcase(test_path) print (test_normcase)   # d:\......\computer_program\py\practice   Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: os.path - join 함수

파이썬(Python): os.path 모듈 - join 함수(function) /// 설명 하나 혹은 그 이상의 경로의 구성요소를 결합합니다. 각 인자의 요소를 결합한 후 경로를 반환하는데, 마지막 요소가 빈 문자열이면 구분자 '/' 를 마지막에 덧 붙입니다. 만약 마지막 요소가 절대경로라면 그 이전의 요소들은 전부 삭제되고 마지막 절대경로를 반환합니다. ※ 형식 os.path.join(path) /// 예제 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 import  os.path   test_path  =  os.getcwd()   # 현재 디렉토리를 반환합니다. print (test_path) # D:\......\Computer_Program\Py\Practice     test_path1  =   'D:\......\Computer_Program' test_path2  =   'Py' test_path3  =   'Example' test_path4  =   '' test_join  =  os.path.join(test_path1, test_path2) print (test_join)   # D:\......\Computer_Program\Py   test_join  =  os.path.join(test_path1, test_path2, test_path3) print (test_join)   # D:\......\Computer_Program\Py\Example   test_join  =  os.path.join(test_path1, test_path2, test_path3, test_path4) print (test_join)   # D:\......\Computer_Program\Py\Example\   test_join  =  os.path.join(test_path1, test_path

파이썬[Python]: os.path - islink 함수

파이썬(Python): os.path 모듈 - islink 함수(function) /// 설명 경로가 symbolic link라면 True를 반환하고, 그렇지 않으면 False를 반환합니다. 만약 simbolic link가 파이썬 runtime에 의해 지원되지 않으면 False를 반환합니다. ※ 형식 os.path.islink(path) /// 예제 1 2 3 4 5 6 7 8 9 import  os.path   test_path  =  os.getcwd()   # 현재 디렉토리를 반환합니다. print (test_path) # D:\......\Computer_Program\Py\Practice   test_islink  =  os.path.islink(test_path) print (test_islink)   # False   Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: os.path - isdir 함수

파이썬(Python): os.path 모듈 - isdir 함수(function) /// 설명 존재하는 경로(디렉토리)라면 True를 반환하고 그렇지 않으면 False를 반환합니다. 이것은 심볼릭 링크를 따르는데, islink()와 isfile() 둘 다 True 일 수 있습니다. ※ 형식 os.path.isdir(path) /// 예제 1 2 3 4 5 6 7 8 9 import  os.path   test_path  =  os.getcwd()   # 현재 디렉토리를 반환합니다. print (test_path) # D:\......\Computer_Program\Py\Practice   test_isdir  =  os.path.isdir(test_path) print (test_isdir)   # True   Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: os.path - isfile 함수

파이썬(Python): os.path 모듈 - isfile 함수(function) /// 설명 경로에 존재하는 파일이라면 True를 반환하고 그렇지 않으면 False를 반환합니다. 이것은 심볼릭 링크를 따르는데, islink()와 isfile() 둘 다 True 일 수 있습니다. ※ 형식 os.path.isfile(path) /// 예제 1 2 3 4 5 6 7 8 9 10 11 12 13 import  os.path   test_path  =  os.getcwd()   # 현재 디렉토리를 반환합니다. test_file  =   '\main.py' print (test_path  +  test_file) # D:\......\Computer_Program\Py\Practice\main.py   test_isfile  =  os.path.isfile(test_path) print (test_isfile)   # False   test_isfile  =  os.path.isfile(test_path  +  test_file) print (test_isfile)   # True   Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: os.path - isabs 함수

파이썬(Python): os.path 모듈 - isabs 함수(function) /// 설명 절대경로이면 True, 그렇지 않으면 False를 반환합니다. ※ 형식 os.path.isabs(path) /// 예제 1 2 3 4 5 6 7 8 9 10 11 12 import  os.path   test_path  =  os.getcwd()   # 현재 디렉토리를 반환합니다. print (test_path) # D:\......\Computer_Program\Py\Practice   test_getisabs  =  os.path.isabs(test_path) print (test_getisabs)   # True   test_getisabs  =  os.path.isabs( './' ) print (test_getisabs)   # False   Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: os.path - getsize 함수

파이썬(Python): os.path 모듈 - getsize 함수(function) /// 설명 경로의 크기를 byte단위로 반환합니다. ※ 형식 os.path.getsize(path) /// 예제 1 2 3 4 5 6 7 8 9 10 import  os.path   test_path  =  os.getcwd()   # 현재 디렉토리를 반환합니다. test_file  =   '\main.py' print (test_path  +  test_file) # D:\......\Computer_Program\Py\Practice\main.py   test_getsize  =  os.path.getsize(test_path  +  test_file) print (test_getsize)   # 296   Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: os.path - getctime 함수

파이썬(Python): os.path 모듈 - getctime 함수(function) /// 설명 시스템상의 ctime을 반환합니다.(Unix계열에서는 마지막으로 meta data가 변경된시간이고, windows에서는 경로가 만들어진 시간입니다.) 반환값은 epoch 부터 지금까지를 초단위(실수값)로 나타낸 값입니다. ※ 형식 os.path.getctime(path) /// 예제 1 2 3 4 5 6 7 8 9 10 11 12 13 14 import  time import  os.path   test_path  =  os.getcwd()   # 현재 디렉토리를 반환합니다. print (test_path) # D:\......\Computer_Program\Py\Practice   test_getctime  =  os.path.getctime(test_path) print (test_getctime)   # 1636887491.1291444   test_gmtime  =  time.gmtime(test_getctime) test_strtime  =  time.strftime( "%a, %d %b %Y %H:%M:%S +0000" , test_gmtime) print (test_strtime)   # Sun, 14 Nov 2021 10:58:11 +0000   Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: os.path - getmtime 함수

파이썬(Python): os.path 모듈 - getmtime 함수(function) /// 설명 경로에서 마지막으로 수정이 일어난 시간을 반환합니다. 반환값은 epoch 부터 지금까지를 초단위(실수값)로 나타낸 값입니다. ※ 형식 os.path.getmtime(path) /// 예제 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 import  time import  os.path   test_path  =  os.getcwd()   # 현재 디렉토리를 반환합니다. test_file  =   '\main.py' print (test_path  +  test_file) # D:\......\Computer_Program\Py\Practice\main.py   test_getmtime  =  os.path.getmtime(test_path) print (test_getmtime)   # 1636887491.1291444   test_gmtime  =  time.gmtime(test_getmtime) test_strtime  =  time.strftime( "%a, %d %b %Y %H:%M:%S +0000" , test_gmtime) print (test_strtime)   # Sun, 14 Nov 2021 10:58:11 +0000   Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: os.path - getatime 함수

파이썬(Python): os.path 모듈 - getatime 함수(function) /// 설명 경로에 마지막으로 접근한 시간을 반환합니다. 반환값은 epoch 부터 지금까지를 초단위(실수값)로 나타낸 값입니다. ※ 형식 os.path.getatime(path) /// 예제 1 2 3 4 5 6 7 8 9 10 11 12 13 14 import  time import  os.path   test_path  =  os.getcwd()   # 현재 디렉토리를 반환합니다. print (test_path) # D:\......\Computer_Program\Py\Practice   test_getatime  =  os.path.getatime(test_path) print (test_getatime)   # 1636887491.1291444   test_gmtime  =  time.gmtime(test_getatime) test_strtime  =  time.strftime( "%a, %d %b %Y %H:%M:%S +0000" , test_gmtime) print (test_strtime)   # Sun, 14 Nov 2021 10:58:11 +0000   Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: os.path - lexists 함수

파이썬(Python): os.path 모듈 - lexists 함수(function) /// 설명 path가 존재하는 경로라면 True를 반환하고, 그렇지 않고 링크가 깨져 있다면 False를 반환합니다. ※ 형식 os.path.lexists(path) /// 예제 1 2 3 4 5 6 7 8 9 10 11 import  os.path   test_path  =  os.getcwd()   # 현재 디렉토리를 반환합니다. print (test_path) # D:\......\Computer_Program\Py\Practice   print (os.path.lexists(test_path))   # True   print (os.lstat(test_path)) # os.stat_result(......)   Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: os.path - exists 함수

파이썬(Python): os.path 모듈 - exists 함수(function) /// 설명 path가 존재하는 경로이거나 열려있는 파일 서술자라면 True를 반환하고, 그렇지 않고 링크가 깨져 있다면 False를 반환합니다.(퍼미션이 없을 경우도 False를 반환할 수 있습니다.) ※ 형식 os.path.exists(path) /// 예제 1 2 3 4 5 6 7 8 9 10 11 import  os.path   test_path  =  os.getcwd()   # 현재 디렉토리를 반환합니다. print (test_path) # D:\......\Computer_Program\Py\Practice   print (os.path.exists(test_path))   # True   print (os.stat(test_path))   # 퍼미션이 없으면 False 반환 가능성 # os.stat_result(......)   Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: os.path - dirname 함수

파이썬(Python): os.path 모듈 - dirname 함수(function) /// 설명 현재 경로의 상위 경로를 반환합니다.(현재경로 = dirname() + basename()) ※ 형식 os.path.dirname(path) /// 예제 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 import  os.path   test_path  =  os.getcwd()   # 현재 디렉토리를 반환합니다. print (test_path) # D:\......\Computer_Program\Py\Practice   test_dirname  =  os.path.dirname(test_path) print (test_dirname) # D:\......\Computer_Program\Py   # path = dirname() + basename() test_dirname  =  os.path.dirname(test_path) test_basename  =  os.path.basename(test_path) print (test_dirname  +   '\\'   +  test_basename) # D:\......\Computer_Program\PyPractice   test_path  =  os.getcwd()  +   '\\main.py' print (test_path) # D:\......\Computer_Program\Py\Practice\main.py   test_dirname  =  os.path.dirname(test_path) print (test_dirname) # D:\......\Computer_Program\Py\Practice cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: os.path - commonprefix 함수

파이썬(Python): os.path 모듈 - commonprefix 함수(function) /// 설명 경로명의 배열들 중에서 같은 문자가 있을때까지의 문자열을 반환합니다.(commonpath + 같은 문자) ※ 형식 os.path.commonprefix(path_list) /// 예제 1 2 3 4 5 6 7 8 9 10 11 import  os.path   test_list  =  [ 'D:\......\Computer_Program\P' ,  'D:\......\Computer_Program\Py\Practice' ] test_path  =  os.path.commonprefix(test_list) print (test_path) # D:\......\Computer_Program\P   test_path  =  os.path.commonpath(test_list) print (test_path) # D:\......\Computer_Program   Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –