ํด๋น ๊ฒฝ๋ก์ ๋๋ ํ ๋ฆฌ๋ฅผ list ํํ๋ก ๋ฐํ
os.listdir(path)
Data๋ฅผ ํฌํจํ๋ ํ์ผ๋ช ์ฐพ๊ธฐ
file_name = [s for s in files if "Data" in s]
with os.scandir(path) as files:
for file in files:
print(file.name)
ํ์ผ ๋ณต์ฌ ํ๊ธฐ
ํ์ผ์ ๋ณต์ฌํ๋ copyfile, copy, copy2 ํจ์๋ ๊ธฐ๋ณธ์ ์ธ ์ฌ์ฉ๋ฐฉ๋ฒ์ ๊ฐ์ต๋๋ค.
import shutil
shutil.copyfile("./test1/test1.txt", "./test2.txt")
shutil.copy("./test1/test1.txt", "./test3.txt")
shutil.copy2("./test1/test1.txt", "./test4.txt")
copyfile๊ณผ copy๋ ๋ฉํ์ ๋ณด๋ ๋ณต์ฌ๋์ง ์์ต๋๋ค.
copy2๋ ๋ฉํ์ ๋ณด๋ ๋ณต์ฌํฉ๋๋ค.
์ฆ, copy2๋ฅผ ์ฌ์ฉํ๋ฉด ํ์ผ์ ์์ฑํ ๋ ์ง๋ ๋ณต์ฌ๋์ง๋ง copyfile๊ณผ copy๋ ํ์ผ์ ์์ฑํ ๋ ์ง๊ฐ ๋ณต์ฌํ ๋ ์ง๋ก ๋ณ๊ฒฝ๋ฉ๋๋ค.
https://blog.naver.com/hankrah/221826518915
024 ํ์ด์ฌ ํ์ผ ๋ค๋ฃจ๊ธฐ - 02. ๋๋ ํ ๋ฆฌ ๋ฆฌ์คํธ
#ํ์ด์ฌ #python #ํ์ผ๋ค๋ฃจ๊ธฐ #ํ์ผ #file #open #read #write #readline #readlines #seek #file_pointer ...
blog.naver.com
https://blog.naver.com/hankrah/221829206710
027 ํ์ด์ฌ ํ์ผ ๋ค๋ฃจ๊ธฐ - 05. ํ์ผ๋ช ํจํด ๋งค์นญ
#ํ์ด์ฌ #python #ํ์ผ๋ค๋ฃจ๊ธฐ #ํ์ผ #file #open #read #write #readline #readlines #seek #file_pointer ...
blog.naver.com
https://ponyozzang.tistory.com/439
Python ํ์ผ, ํด๋ ๋ณต์ฌ(shutil) ์ฌ์ฉ ๋ฐฉ๋ฒ ์์
ํ์ผ์ ๋ณต์ฌํ๊ฑฐ๋ ํด๋๋ฅผ ๋ณต์ฌํ๊ณ ์ถ์ ๊ฒฝ์ฐ๊ฐ ์์ต๋๋ค. copyfile, copy, copy2 ํจ์๋ฅผ ์ฌ์ฉํด์ ๋ณต์ฌ๊ฐ ๊ฐ๋ฅํฉ๋๋ค. ํ์ง๋ง ์กฐ๊ธ์ฉ ์ฐจ์ด๊ฐ ์์ต๋๋ค. ํ์ผ ๋ณต์ฌ ํ๊ธฐ ํ์ผ์ ๋ณต์ฌํ๋ copyfile, copy,
ponyozzang.tistory.com
'Python > Basic' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Python] Pillow ์ด๋ฏธ์ง ์ฌ์ด์ฆ ํ์ธ (0) | 2022.08.06 |
---|---|
[Python] PDF ๊ด๋ จ ํจํค์ง ์ ๋ฆฌ (0) | 2022.08.05 |
[Python] Excel, Word ๋ค๋ฃจ๊ธฐ (0) | 2021.07.26 |
[Python] XlsxWriter - Excel ๋ค๋ฃจ๊ธฐ (0) | 2021.07.26 |
[Python] sqlalchemy, json์ผ๋ก ๋ณ๊ฒฝ ํ ๋ฆฌํด (2) | 2021.04.16 |