shutil

    1熱度

    2回答

    Documents = ['*pdf', '*docx', '*txt'] for i in range(len(Documents)): if glob.glob(Documents[i]): print(Documents[i], True) shutil.move(glob.glob(Documents[i])[0], '/home') el

    0熱度

    1回答

    我想將一個文件複製到另一個文件。從this thread接受的答案,我已經做了: def fcopy(src): dst = os.path.splitext(src)[0] + "a.pot" try: shutil.copy(src, dst) except: print("Error in copying " + src) s

    0熱度

    1回答

    我想從一個文件夾複製文本文件到另一個在Python中使用shutil。我寫了下面幾行: import shutil path_to_text= 'C:\pyprog\sample.txt' dest = 'C:\pyprog\dest' 但每次我把這個代碼時,我得到errno的2.錯誤的回溯是 Traceback (most recent call last): File "<stdin>

    1熱度

    1回答

    我想寫一個簡單的腳本來將文件從一個文件夾移動到另一個文件夾並過濾不必要的東西。我使用下面的代碼,但接收到錯誤 import shutil import errno def copy(src, dest): try: shutil.copytree(src, dest, ignore=shutil.ignore_patterns('*.mp4', '*.bak'))

    -2熱度

    1回答

    「」「我正在使用此程序執行四個不同文件中的文本替換,然後將其與tepmplate進行比較,然後一個新的文件,從四個不同的文件粘貼到特定 位置替換文本在一個單一的file.Create。「」」 #FILES directory contains four text file with FIRST FILE OLD TEXT and this has been # replaced with FIR

    2熱度

    2回答

    我正在嘗試編寫一個簡短的Python腳本,它將從具有特定擴展名的目錄中複製所有文件,並將它們放在不同的文件夾中。下面是該腳本: import os, shutil source = "C:\\TCR_Calgary\\projects\\" destination = "C:\\TCR_Calgary\\reference\\my_code\\city_of_calgary_scripts

    0熱度

    1回答

    我已經知道如何打印文件中使用shutil.copyfileobj到stdout後Shutil.copyfileobj載重線,它的工作是這樣的: with open('filename.extension', 'r') as file: shutil.copyfileobj(file, sys.stdout) 不幸的是我,當它這樣做,它一次打印整個文件。我不希望它這樣做。我希望它逐行逐

    0熱度

    1回答

    我正在嘗試創建一個將文件從遠程服務器複製到本地驅動器的python腳本。問題是我注意到它沒有生成一個線程來並行複製其他文件。 import shutil import threading LocalPath = "C:\\folder1" RemotePath = "X:\\folder1" # downloader/copier def monitorCopy (Filename)

    0熱度

    1回答

    所以我有一個python程序,寫入素數到csv文件。我現在希望我的python文件在運行所有內容後創建它自己的副本,作爲我對原始文件進行調整時的備份。 到目前爲止,我已經不知道這一點了,通過讓python程序創建一個新的.py文件,然後在其中寫入所有內容,但這是非常低效的。我希望它更簡潔,更簡單。 我聽說過使用shutil.copyfile一點點,但我不太確定如何使用它。 shutil.copyf

    1熱度

    1回答

    import sys import os import shutil def main(argv): if len(argv) < 3: print("To few arguments") return 1 dir = os.path.dirname(__file__) latencyMonitorDir = argv[1]