Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/we684123/get-filename
我絕對不要再為了這個坑花了整整2小時 Orz......
https://github.com/we684123/get-filename
Last synced: about 5 hours ago
JSON representation
我絕對不要再為了這個坑花了整整2小時 Orz......
- Host: GitHub
- URL: https://github.com/we684123/get-filename
- Owner: we684123
- License: mit
- Created: 2019-07-24T06:57:17.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-09-10T17:59:22.000Z (about 4 years ago)
- Last Synced: 2024-11-09T00:52:59.070Z (8 days ago)
- Language: Python
- Homepage:
- Size: 36.1 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# get_filename
我絕對不要再為了這個坑花了整整2小時 Orz......
如題,只是一個獲取檔案名稱或副檔名的東東。From a filename(str) get extension or name.
----
# 安裝 install```
pip install get-filename
```----
# 用法 how to use
**get_filename( filename=str, mode='filename', index=0):**@param {str} filename (不能為空)
@param {str} mode ('filename' or 'extension') or ( 1 or 2)
@param {int} index (當 mode = 'extension' 或 2 才會作用)
@return {str}ex1 :
t = get_filename('explosion.hard.txt')
t -> 'explosion.hard'ex2 :
t = get_filename('/path/to/somefile.ext')
t = 'somefile'ex3 :
t = get_filename('explosion.hard.txt','extension',-3)
t = get_filename('explosion.hard.txt',2,0)
t -> 'explosion'ex4 :
t = get_filename('/path/to/somefile.txt','extension',-1)
t = get_filename('/path/to/somefile.txt',2,-1)
t -> 'txt'