Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python file directory

from os import path
dir_path = path.dirname(__file__)
Comment

python working with files and dirs

from pathlib import Path
import shutil

tmp = Path("/tmp")

src = tmp.joinpath("src")
src.mkdir()
src.joinpath("src.txt").touch()
# /tmp/src
# /tmp/src/src.txt

dst = tmp.joinpath("dst")
dst.mkdir()
# /tmp/dst

shutil.copytree(src, dst)
# FileExistsError: [Errno 17] File exists: '/tmp/dst'
shutil.copytree(src, dst, dirs_exist_ok=True)
# PosixPath('/tmp/dst')
Comment

PREVIOUS NEXT
Code Example
Python :: a int and float. python 
Python :: pandas pivot to sparse 
Python :: marshmallow default value 
Python :: can serializer returns an object in django 
Python :: activate virtual environment 
Python :: django channel 
Python :: sort dict of dicts by key 
Python :: pandas groupby most frequent 
Python :: python get total gpu memory 
Python :: create array of specific size python 
Python :: how to sort a list in python 
Python :: how to write a dataframe to s3 object in python 
Python :: how to convert string to integer in python 
Python :: free download django app for windows 10 
Python :: python factor number 
Python :: multi threading in python for 2 different functions with return 
Python :: how to get the length of a string in python 
Python :: post list python 
Python :: check if string match regex python 
Python :: merge keep left index 
Python :: get files in directory and subdirectory 
Python :: select random img in python using os.listdir 
Python :: numpy evenly spaced numbers 
Python :: dict column to be in multiple columns python 
Python :: usage of thread in python 
Python :: Convert datetime object to a String of date only in Python 
Python :: Using Lists as Queues 
Python :: dtype array 
Python :: print to file python 
Python :: condition python 
ADD CONTENT
Topic
Content
Source link
Name
9+7 =