Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python using os module file name from file path

import os

# file name with extension
file_name = os.path.basename('/root/file.ext')

# file name without extension
print(os.path.splitext(file_name)[0])
Comment

python using os module file name from file path

from pathlib import Path

print(Path('/root/file.ext').stem)
Comment

PREVIOUS NEXT
Code Example
Python :: python pip past 
Python :: format exponentials python 
Python :: python get global variable by name 
Python :: python how to locate and fill a specific column null values 
Python :: python remove table widget numbers 
Python :: append string variable with integer python 
Python :: flatten list in python 
Python :: upload folder to s3 bucket python 
Python :: searching for best k values in knn 
Python :: numpy percentile 
Python :: how to create a spark schema using a string 
Python :: python get substring 
Python :: base64 python 
Python :: python cointegration 
Python :: embeds discord.py 
Python :: if any number python 
Python :: from sklearn.metrics import confusion_matrix pred = model.predict(X_test) pred = np.argmax(pred,axis = 1) y_true = np.argmax(y_test,axis = 1) 
Python :: turn off yticklabels 
Python :: python switch item 
Python :: python overwrite multiline text 
Python :: mid-point circle drawing 
Python :: python indent print 
Python :: python append 
Python :: Python NumPy stack Function Example with 1d array 
Python :: python dict add item 
Python :: Python NumPy asfarray Function Example Tuple to float type array 
Python :: save a preprocess text 
Python :: .dropna() python 
Python :: import csv 
Python :: label_map dict = label_map_util.get_label_map_dict(label_map) 
ADD CONTENT
Topic
Content
Source link
Name
6+9 =