Skip to main content

from a filename(str) extension or name

Project description

get_filename

我絕對不要再為了這個坑花了整整2小時 Orz......
如題,只是一個獲取檔案名稱或副檔名的東東。

From a filename(str) get extension or name.


用法 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'

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for get-filename, version 1.0.0
Filename, size File type Python version Upload date Hashes
Filename, size get_filename-1.0.0-py3.8.egg (3.6 kB) File type Egg Python version 3.8 Upload date Hashes View
Filename, size get_filename-1.0.0-py3-none-any.whl (3.4 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size get_filename-1.0.0.tar.gz (2.2 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page