精品偷拍一区二区三区,亚洲精品永久 码,亚洲综合日韩精品欧美国产,亚洲国产日韩a在线亚洲

  • <center id="usuqs"></center>
  • 
    
  • I don't know how to use baiduhi.Can you tell me how to solve the following problem?

    I don't know how to use baiduhi.Can you tell me how to solve the following problem?
    假設(shè)有個(gè)目錄下有很多個(gè)文件夾,分為兩類(lèi) A和B,A里面都是.txt文檔,B里面又有文件夾,二文件夾 下才是.txt 怎樣把A中.txt單獨(dú)壓縮在A文件夾里,B中以則子文件夾為單位壓縮在B中
    Assuming that a directory has many folders.There are two types of these folders,A and B.
    In the A ,all the documents are .txt documents.But B has lots of folders like A.
    How to put .TXT compression alone in A
    and put subfolders compression in the B
    英語(yǔ)人氣:203 ℃時(shí)間:2020-03-30 00:19:38
    優(yōu)質(zhì)解答
    Gotha,wait a moment,I'm writing it.
    This code is written according to the cases you just described
    the APath and BPath should be the path of A and B folder.
    #
    import tarfile
    import os
    APath = 'A'
    dirA = os.walk(APath).next()[2]
    tarA = tarfile.open('A/txt.tar.bz','w:bz2')
    for file in dirA:
    tarA.add(os.path.join(APath,file))
    tarA.close()
    BPath = 'B'
    dirB = os.walk(BPath).next()[1]
    os.chdir('B')
    for directory in dirB:
    tar = tarfile.open(directory+'tar.bz','w:bz2')
    tar.add(directory)
    tar.close()
    我來(lái)回答
    類(lèi)似推薦
    請(qǐng)使用1024x768 IE6.0或更高版本瀏覽器瀏覽本站點(diǎn),以保證最佳閱讀效果。本頁(yè)提供作業(yè)小助手,一起搜作業(yè)以及作業(yè)好幫手最新版!
    版權(quán)所有 CopyRight © 2012-2024 作業(yè)小助手 All Rights Reserved. 手機(jī)版