Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

get the name of a file using os

>>> list_of_names_in_directory = os.listdir('path/of/directory')
Comment

os.filename

import os
file_location = '/srv/volume1/data/eds/eds_report.csv'
file_name = os.path.basename(file_location )  #eds_report.csv
location = os.path.dirname(file_location )    #/srv/volume1/data/eds
Comment

os.filename

import os
file_location = '/srv/volume1/data/eds/eds_report.csv'
file_name = os.path.basename(file_location )  #eds_report.csv
location = os.path.dirname(file_location )    #/srv/volume1/data/eds
Comment

PREVIOUS NEXT
Code Example
Python :: delete plotted text in python 
Python :: matplotlib remove drawn text 
Python :: crypto trading bot python 
Python :: pysimplegui get value from textbox 
Python :: turn string into operator python 
Python :: how to write a function in python 
Python :: channels_redis 
Python :: install python package 
Python :: get date only from datetimefiel django 
Python :: How To Display An Image On A Tkinter Button 
Python :: find an item in a list python 
Python :: python import list from py file 
Python :: conv2d default stride 
Python :: django migrations 
Python :: Convert a Pandas Column of Timestamps to Datetimes 
Python :: list count python 
Python :: attributes in python 
Python :: python create dictionary 
Python :: import from parent directory python 
Python :: python pyttsx3 
Python :: docker compose cron 
Python :: atoi in python code 
Python :: iteration 
Python :: numpy rolling 
Python :: loading bar in python 
Python :: is login a class in python 
Python :: converting time 
Python :: python built in libraries 
Python :: python code variable declaration 
Python :: kwargs in python 
ADD CONTENT
Topic
Content
Source link
Name
5+4 =