Skip to main content

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'

Metadata

Release files for get-filename 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for get-filename 1.0.0
File Size Uploaded
get_filename-1.0.0.tar.gz 2.2 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for get-filename 1.0.0
File Interpreter ABI Platform
get_filename-1.0.0-py3.8.egg Legacy Egg format - - Details
get_filename-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 9.2 kB

Release files / get_filename-1.0.0.tar.gz

Download URL get_filename-1.0.0.tar.gz
Size 2.2 kB
Tags Source
SHA-256 checksum
How to use checksums
7cbfd90dd4a6a84bddb04b8924eebec8e218bc9578152e27589ab5814b13d208
BLAKE2b-256 checksum
How to use checksums
b20a3d8c177463b9a646ee40903138230bf2f04322123bf3cc8cee8c71025287
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.2

Release files / get_filename-1.0.0-py3.8.egg

Download URL get_filename-1.0.0-py3.8.egg
Size 3.6 kB
Tags Egg
SHA-256 checksum
How to use checksums
c3f734211638519504af390c94d4333d41a7754950d80f81c4e601cb8104d3a7
BLAKE2b-256 checksum
How to use checksums
74abe8de553e9de9d68fb1bb356b623e7ae439499980b1d4a2907d8fa5f1f54f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.2

Release files / get_filename-1.0.0-py3-none-any.whl

Download URL get_filename-1.0.0-py3-none-any.whl
Size 3.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
acaf7e7d19d84de5aed8c3a98e86ea151dc319086aeb8608af93b79cf90946ec
BLAKE2b-256 checksum
How to use checksums
736f6a97183aca9fd5075f1d63b52b52b8fa5d526104f3a482f2a81bb31888ad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.2

Release history Release notifications | RSS feed

This release

1.0.0 This release

3 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page