“Plik Python Move” Kod odpowiedzi

Plik Python Move

# To move a file in Python, use one of the following:
import os
import shutil

os.rename("path/to/current/file.foo", "path/to/new/destination/for/file.foo")
shutil.move("path/to/current/file.foo", "path/to/new/destination/for/file.foo")
os.replace("path/to/current/file.foo", "path/to/new/destination/for/file.foo")

# In the first two cases the directory in which the new file
# is being created must already exist.
SkelliBoi

Plik Python Move

import os, shutil
#move picture.png from /some/dir/ to /another/dir/Pictures/
shutil.move('/some/dir/picture.png', '/another/dir/Pictures/')
Victorious Vendace

Plik Plik Python

import os
import shutil

os.rename("path/to/current/file.foo", "path/to/new/destination/for/file.foo")
shutil.move("path/to/current/file.foo", "path/to/new/destination/for/file.foo")
os.replace("path/to/current/file.foo", "path/to/new/destination/for/file.foo")
Dead Dog

przesuń plik Python OS

import os
import shutil

os.rename("path/to/current/file.foo", "path/to/new/destination/for/file.foo")
os.replace("path/to/current/file.foo", "path/to/new/destination/for/file.foo")
shutil.move("path/to/current/file.foo", "path/to/new/destination/for/file.foo")
BlueMoon

Przenieś pliki w Python

import shutil
original = r'original path where the file is currently stored\file name.file extension'
target = r'target path where the file will be moved\file name.file extension'
shutil.move(original,target)
Real Raccoon

Odpowiedzi podobne do “Plik Python Move”

Pytania podobne do “Plik Python Move”

Więcej pokrewnych odpowiedzi na “Plik Python Move” w Python

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu