반응형
기본 이름이없는 파일 경로
파일 basename없이 파일의 경로를 어떻게 얻을 수 있습니까?
/a/path/to/my/file.txt
-> 같은 것/a/path/to/my/
성공하지 않고 .split () 시도
사용 os.path.dirname(filename)
.
당신은 할 수 있습니다 import os
>>> filepath
'/a/path/to/my/file.txt'
>>> os.path.dirname(filepath)
'/a/path/to/my'
>>>
(dirname, filename) = os.path.split(path)
구독자 확인 os.path
os.path.dirname('/test/one')
참조 URL : https://stackoverflow.com/questions/11757520/path-to-a-file-without-basename
반응형
'programing' 카테고리의 다른 글
jQuery에서 "this"는 무엇을 의미합니까? (0) | 2021.01.14 |
---|---|
matplotlib의 작은 산점도 마커는 항상 검은 색입니다. (0) | 2021.01.14 |
Android SDK 관리자의 MIPS 시스템 이미지는 무엇입니까? (0) | 2021.01.14 |
파일 무결성을위한 SHA-256 또는 MD5 (0) | 2021.01.14 |
수식 조건으로 "셀에 # N / A가 포함 된 경우"사용. (0) | 2021.01.14 |