获取指定文件夹下所有的同种类型文档的名字(Python)

  • Post author:
  • Post category:python


今天教大家如何在一个非常混乱文件夹下用Python编写一个程序来寻找所有自己所需类型的文件(这次举例选择json文件,如果有寻找其他类型文件需要可下面程序json改为自己所需的文件名字),并且输出所有所需文件的名字。

首先我们需要导入系统的os库,这个库不需要再下载。


from os import listdir

其次我们将需要寻找的文件夹路径赋值给path,在使用listdir()函数将此文件夹下的所有文件转为list类型。


path = ‘./cat_valid/CAT_06/’

目录下的部分文件截图:

使用listdir函数获取此目录下所有文件名称。


filelist = listdir(path)

定义filelist1来存放所需文件的名字。


filelist1=[]

使用for循环遍历此文件夹下所有文件,利用split对其进行分词,获取文件的类型名字。


for i in range(0,len(filelist)):



index = filelist[i].split(“.”)[-1]

使用if对所需文件类型进行判断,此处可将‘json’改为所需的‘doc’,‘tex’,‘jpg’等类型,当然也可以多定义几个filelist1列表来对这些文件类型全部统计。


if index==’json’:



filelist1.append(filelist[i])



print(filelist1)

最后运行程序即可输出此文件夹下所有自己所需的文件类型名字。

运行结果为:

[‘janessa-broadbridge-202107-petportraitgift-web.jpg?1629132765.json’, ‘20180314105344_kWHM3.json’, ‘20190807152043_RMRkH.json’, ‘20180702112109_8Zl8k.json’, ‘f8961490974101.5e25d07464505.json’, ‘20180128104615_xmFKk.json’, ‘destiara_12-compress-20220413-074934-4983.jpg?1649812507.json’, ‘20191129110230_r3w8E.json’, ‘20180314105354_BcWGx.json’, ‘Cats 2020.json’, ‘20190905114316_LAVyH.json’, ‘2021-06-24 20.27.49 2603133101651526880_1390548623.json’, ‘20180314110045_xr2Ly.json’, ’01d2ab5dfa174fa801216518e76565.json’, ’01ab305fb90c4d11013ee04ddf6d8a.json’, ‘20180314110006_XKvhZ.json’, ‘cati-fornia-watercolor-kitty-portrait-for-a-cat-lover-friend-by-catifornia.jpg?1548553050.json’, ‘20191110101654_VFsYh.json’, ‘20170930122100_uwdkm.json’, ‘dekoci-asset.jpg?1615292109.json’, ‘ec691dfbae8c6ab323f340e4facdb905.json’, ‘brooke-img-3925.jpg?1621891749.json’, ‘20170818094742_Z8fBQ.json’, ‘eris_ink22-eris-img-20220103-144158-322.jpg?1641242052.json’, ‘20190930113355_EGLVT.json’, ‘f6e2916c4aed468da0390240d550e45d.json’, ‘20171001114344_aj2cG.json’, ‘ellie-brown-rachaels-painting.jpg?1571307277.json’, ‘2021-07-17 20.55.18 2619816772357971181_1390548623.json’, ‘cati-fornia-caturday-portrait-june-2nd-edition-by-catifornia.jpg?1528159136.json’, ‘indah-siregar-batuganasmall.jpg?1516949804.json’, ‘jennifer-fryer-ben-rgb.jpg?1622659185.json’, ‘e74eb63655dccf8b58218e3e37d78df5.json’, ‘20170930122111_mENcs.json’, ‘20190106110418_Y5GQd.json’, ‘20181220103838_ZVPKG.json’, ‘elysia-womersley-meatballreframed.jpg?1597049922.json’, ‘20171001122848_ZaMmf.json’, ‘20171114114651_Si5QP.json’, ‘2021-08-08 13.11.49 2635528561516368250_13580129163.json’, ‘2021-07-08 20.28.11 2613280145884107745_1390548623.json’, ‘20180929110853_M5hMN.json’, ‘20180314105906_x5d4m.json’, ‘20180625125139_slTzY.json’, ‘20190108110120_SlUXa.json’, ‘20191110101618_zX5xa.json’, ‘dacef215f8b8478284d003f1bad85c51.json’, ‘20191110112522_ndEdk.json’, ’01ddd35b83587ba80120577d3e280c.json’, ‘20180314110401_SLrvz.json’, ‘diana-marante-asset.jpg?1610969340.json’, ‘20171114114603_f34iC.json’, ‘christina-helmich-reqcat-kopie.jpg?1594586921.json’, ‘2021-06-29 20.21.44 2606753918130209355_1390548623.json’, ‘20190901125552_nU2Vc.json’, ‘gabriela-borta-cat-oil-paint-x.jpg?1631044142.json’, ’emily-stagg-bean.jpg?1624496723.json’, ‘danyon-street-commission-amber.jpg?1575879072.json’, ‘20180207100313_PmCJn.json’, ‘20180314110312_iFhGx.json’, ‘elen-galteland-aby-superstar.jpg?1430579332.json’, ‘20180721164350_krqss.json’, ‘daniela-l-txfinal.jpg?1633867778.json’, ‘2021-07-09 20.43.55 2614012835050758285_1390548623.json’, ’01d0135f7343de11013f3110c1276b.json’, ‘20180128104714_TvrSR.json’, ‘frank-ace-asset.jpg?1610499569.json’, ‘20170710113849_akSFm.json’, ‘igor-kozhanov-my-cat.jpg?1453138230.json’, ‘ca39f9146767277.62b5e82be4562.json’, ‘e527ed90974101.5e25d07463636.json’, ‘20170710104808_jG432.json’, ‘jacob-smith-rc08-dora-arikaru-katotokari-frameless.jpg?1572452549.json’, ‘20170818094824_5EMwh.json’, ‘elena-luchkina-20.jpg?1627077165.json’, ‘20190930113008_CxtU4.json’, ‘dale-jackson-painting-of-a-cat-snuggles.jpg?1588015600.json’, ‘20180416112913_KHdFl.json’, ‘20190828124418_Vfa8d.json’, ‘butter-h-asset.jpg?1624456504.json’, ‘high-kixx-art-img-7414.jpg?1639311227.json’, ‘01059d6105637711013f4720ec0db4.json’, ‘evelina-bage-evelina-bage-sandra-thumbnail.jpg?1635960792.json’, ‘20180314110339_Jz8Ai.json’, ‘df236dcba333461fa582574cbc66269a.json’, ‘20180314105521_AXYur.json’, ‘20181127103321_UY3rF.json’, ‘20180314105752_4fjaY.json’, ‘20171114114629_drKBf.json’, ‘cd26ff2833794056976b63465e367f81.json’, ‘20180314105929_uLBFU.json’, ‘20180702112109_KnS3V.json’, ‘20171001114301_HmZLa.json’, ‘20190722155111_ZsPaw.json’, ‘20180314110031_YQ4uS.json’, ‘dimitri-morake-morgan-commission.jpg?1558017988.json’, ‘20180314105550_diN2m.json’, ‘20190930113015_ysszV.json’, ‘elodie-ufarte-b4c46159-4bfa-46a0-856c-88784f57635f.jpg?1643649780.json’, ‘20181229114748_JizFU.json’, ‘e8aec07e644a9369fc224ce9b246b67e.json’, ‘20171001122747_NAW5G.json’, ‘2021-06-28 20.29.20 2606032967537120424_1390548623.json’, ‘20170701105825_shucy.json’, ‘20171006094236_YZsAP.json’, ‘fabienne-zuijdgeest-kat-uplox-kwaliteit-laag.jpg?1640862775.json’, ‘chloe-carter-eevee-kun-uwu-low-resolution-jpg.jpg?1586503515.json’, ‘20170717113318_PkmLf.json’, ‘20170710113659_FiNG4.json’, ‘20180702112109_8vFte.json’, ’emma-griffiths-lady-evie-final.jpg?1602928549.json’, ’01e086611a87d611013eaf703ef7d7.json’, ‘20190807153620_c2Wwi.json’, ‘20180328113741_RPaaj.json’, ‘deann-hinojosa-asset.jpg?1621898373.json’, ‘20190930113008_5tniV.json’, ‘20180328113224_rEsZy.json’, ‘0100755ec0b478a801207200ed9d7a.json’, ‘20190905114316_Tz3S2.json’, ‘chiara-camilotto-catto-dipinto-jpeg.jpg?1510410701.json’, ‘david-ullmann-mr-oliver-edited.jpg?1513288274.json’, ’01a607554bda1a000001bf7217479e.json’, ‘chen-royal-pet-portrait-12.jpg?1632822634.json’, ‘20180929110853_h8zTG.json’, ‘20190901125552_rEGMM.json’, ‘20180915110818_NcVVM.json’, ‘elodie-ufarte-887d9ebe-e333-4b79-a2a6-974e33a4e5f5.jpg?1613066400.json’, ‘20190901125552_WrHEY.json’, ‘deanna-bradley-caitlin-s-baby.jpg?1531182993.json’, ‘20181229114748_XjXrl.json’, ‘2021-05-27 20.36.15 2582843623936380864_6298000648.json’, ‘e16f9d138775657.6223c46d34bd3.json’, ‘20191129110230_VkVmu.json’, ‘cati-fornia-a-lovely-fairy-girl-with-her-purple-cat-by-catifornia.jpg?1523797801.json’, ‘20190315115327_LZhrl.json’, ‘20180314110353_vm2uA.json’, ‘20180702112109_WWlGW.json’, ‘hypoxiapaints-andy-judd-paint-sketch-commission-by-hypoxiapaints-dev97ob-fullview.jpg?1638310523.json’, ‘20190828124444_mRrfa.json’, ‘elna-aberg-cat-portrait.jpg?1587727024.json’, ‘20191129110230_v8SlK.json’, ‘f66bd73359099ceded2e030c3647450a.json’, ‘jenny-bunte-blackcat-02.jpg?1630404188.json’, ‘da54874dd9cb2030cd5a765c3bc40678.json’, ‘20170804103504_sQPrH.json’, ‘20180315112315_HzAPP.json’, ‘jacob-smith-rc19-tsar-vladimir-alexeyevich-frameless.jpg?1634051227.json’, ‘20170818094703_yXMYs.json’, ‘cati-fornia-halloween-style-vampire-cat-portrait-by-catifornia.jpg?1539104458.json’, ‘20190228100940_jRUYZ.json’, ’01aa5e5d50c6baa80120695ce97b67.json’, ‘2021-08-17 14.03.37 2642077612317195896_13580129163.json’, ‘20180314105444_BsUnk.json’, ‘c61d4ab55057563f015e9664bee7afa0.json’, ‘20191110101624_WPdHw.json’, ‘candace-fujii-tavi1.jpg?1555463588.json’, ‘flaminia-kennedy-dash-by-flaminiakennedy.jpg?1439880462.json’, ‘20171030114332_jMXCt.json’, ‘20190722155111_sWVGl.json’, ‘chen-the-duchess-30×40-3963867594919-21053-final.jpg?1632822723.json’, ‘20190901125552_JlL4C.json’, ‘20180416114045_jGi4M.json’, ‘20191110112522_JNitC.json’, ‘denise-bettenbuhl-einstein.jpg?1564498474.json’, ‘diana-.jpg?1625737658.json’, ‘catvandark-art-s-catvandark-art-s-71.jpg?1540725724.json’, ‘ec67359125e2e2d55af89895bb165079.json’, ‘2021-08-02 21.14.26 2631422815229021276_1390548623.json’, ‘01034a5e7f4003a80120a8954a0a54.json’, ‘20190108110120_rlnz8.json’, ‘diluk-chathuranga-15.jpg?1574100783.json’, ‘doudoubao-233a5454-23ac-47f0-b340-97591955a586.jpg?1650576057.json’, ‘chelsea-noyon-artist-5550b70a-d03e-480b-85b3-fa3907987e56.jpg?1619649120.json’, ‘d52672cca6c49510cffaffa1a265ce4e–himalayan-cat-cartoon-cats.json’, ‘20190106110418_mRiZP.json’, ‘20171001114354_C54fu.json’, ‘2021-06-22 19.12.41 2601645736030563065_1390548623.json’, ‘20190828124418_RKiPW.json’, ‘elke-braat-p-11.jpg?1572959852.json’, ‘20190106110418_RMvek.json’, ‘ed-louchren-asset.jpg?1616046839.json’, ‘2021-06-15 20.07.26 2596599854142615948_1390548623.json’, ‘20170821103026_wcuQr.json’, ‘c79a576fd77da4104d1d067f7995f3cf.json’, ‘catherine-matchan.jpg?1642816242.json’, ‘20190227222302_YysuZ.json’, ‘cati-fornia-watercolor-portrait-for-our-handsome-cat-friend-raven.jpg?1550187893.json’, ‘jacob-smith-rc16-sir-piers-lovell-frameless.jpg?1634051094.json’, ‘20180416112937_xdwGn.json’, ‘christianne-rooke-keltie-and-moses-artstation.jpg?1634687598.json’, ‘elisabeth-aarebrot-madsen-leo-mini.jpg?1637772522.json’, ‘c6f9fec2695c3d414b1676aed61114e1–portraits.json’, ‘2021-08-16 21.12.00 2641568449999337892_1390548623.json’, ‘20191019101550_rTyWd.json’, ‘20180328113744_vZluw.json’, ‘20171030114437_WkxNP.json’, ‘chen-royal-pet-portrait-3.jpg?1632812192.json’, ‘elen-galteland-gresshoppe-er-digg.jpg?1430570872.json’, ‘0102635b55692da8012036be9f9e1f.json’, ‘ioanna-zakharova-ifzrzrg-5zm.jpg?1637363717.json’, ‘20170804103237_kiQEC.json’, ‘jacob-smith-rc04-lord-augustus-pomeroy-the-noble-frameless.jpg?1572370465.json’, ‘elina-misha.jpg?1648478297.json’, ‘hypoxiapaints-andy-judd-paint-sketch-commission-by-hypoxiapaints-devhzvv-fullview.jpg?1638551536.json’, ‘20180416112918_4x3uS.json’, ‘2021-08-28 21.03.11 2650261322122696609_1390548623.json’, ‘diana-marante-asset.jpg?1608919332.json’, ‘chloe-carter-gizmo-low-resolution-jpg.jpg?1586502968.json’, ‘caitlin-sue-nyobi-smol.jpg?1609387606.json’, ‘ea3206117625521.607939a03679e.json’, ‘jennifer-laeben-rosen-newcanvas4.jpg?1591714418.json’, ‘20170710113617_3W4Ej.json’, ‘20180314105510_Ar3HS.json’, ‘20180314110346_dTW3j.json’, ‘20180314110053_Zc5FQ.json’, ‘cati-fornia-watercolor-kitty-portrait-for-our-cat-friend-vivi-the-ragdoll-by-catifornia.jpg?1555600614.json’, ‘20180314105948_fMkLh.json’, ‘0101026115382211013eaf70c278cd.json’, ‘20170726235523_YschH.json’, ‘20181220105351_YlRN8.json’, ’01b8c061223d0611013eaf70406179.json’, ‘isbah-razzaq-jiji-final.jpg?1578425085.json’, ‘david-rivero-jayn.jpg?1600526223.json’, ‘elisabeth-aarebrot-madsen-gunilla-mini.jpg?1601649641.json’, ‘20190108110120_VAk4F.json’, ‘elodie-ufarte-b7b1d86f-fe07-4b58-9a3a-54aa151888ac.jpg?1620389761.json’, ‘f5265f147011829.62bade87b7c9e.json’, ‘20190807152043_PahJE.json’, ’01b4865ef1e563a801215aa01e3143.json’, ‘20180207100309_k4EnC.json’, ‘20180721164351_hmfof.json’, ‘cay-west-artflow-201808291459.jpg?1537872979.json’, ‘2021-05-28 19.09.02 2583524501845270112_1390548623.json’, ‘cande-julieta.jpg?1602765280.json’, ‘connoisseur-dane-cat-2.jpg?1622798580.json’, ‘diana-11.jpg?1643637154.json’, ‘20180128120022_yNsHc.json’, ’01ac5f5f425dc3a801215aa03d4772.json’, ‘20190828124418_kNYzC.json’, ‘jacob-smith-rc12-baroness-rochelle-winchester-frameless.jpg?1634050863.json’, ‘2021-07-15 20.43.15 2618361153448963578_1390548623.json’, ‘jacob-smith-rc17-cardinal-biggles-ximenez-frameless.jpg?1634051143.json’, ‘20180328113220_AEFEF.json’, ‘elisabeth-aarebrot-madsen-froya-mini.jpg?1631281809.json’, ‘20171006124055_hTinM.json’, ’01ac0f61223d1d11013f47204a54f5.json’, ‘gmariagottifredi-20210515-122650-30.jpg?1625826618.json’, ‘20171001122903_Vs3dX.json’, ‘20180328113731_ukQxR.json’, ‘cathleen-cat-obrien-x-commission-three.jpg?1565321302.json’, ‘celila-a-tribute-to-frances-by-llap115-cmyk.jpg?1579725125.json’, ‘d38987f63b7a725cba2fc990c2610627.json’, ‘20180314105638_4m2Qf.json’, ‘helen-aimee-willow-web-final.jpg?1655227856.json’, ‘20180314105459_BNmAZ.json’, ‘20170930122034_LMKYn.json’, ‘f6553b90974101.5e25d07461433.json’, ‘20180315045352_vuurb.json’, ‘-img-20220321-185117.jpg?1647867142.json’, ‘20170804103455_th453.json’, ‘elodie-ufarte-img-e0113.jpg?1604280646.json’, ‘hedwig-bukveen-chx-cat.jpg?1627116750.json’, ‘daniel-ruiz-screen-shot-2021-11-14-at-9-58-24-am.jpg?1637350716.json’, ‘20180314110318_ftNui.json’, ’01a1275fe4956f11013fdcc7a72f76.json’, ‘20170804103257_ETwPs.json’, ‘20181231100723_RKWlf.json’, ‘e69f01c6aa4c03a751a6064aa1297c9a.json’, ‘cass-gray-romeo.jpg?1588883501.json’, ‘20171126091358_CQXVH.json’, ‘20190807153620_QwVx3.json’, ‘elodie-ufarte-273876526-10228299949746510-6965029416421946447-n.jpg?1648051559.json’, ‘carlos-castillo-img-20180729-wa0021.jpg?1565363786.json’, ’01a9d85ec0b476a8012072009954ed.json’, ’01aa9d61b9d5c611013f01cd0a3a60.json’, ‘20180207100248_j2mAw.json’, ‘20190722154942_HJStd.json’, ‘carissa-roby-catportraits.jpg?1552509111.json’, ‘2021-07-30 13.24.55 2629012178021083457_6298000648.json’, ‘20170710115236_AzUXW.json’, ‘jenn-alarza-gatito-rubio.jpg?1586278606.json’, ‘jacob-smith-rc03-lord-theobald-reinhardt-montclair-frameless.jpg?1572369360.json’, ‘20180702112109_8KvSl.json’, ‘izzie-s-monstera-scronch-cat-2.jpg?1641914501.json’, ‘20190108110120_w8RSC.json’, ’01ab24594fd895a8012193a3229c66.json’, ‘erin-obrien-vinz.jpg?1595441050.json’, ‘20180314110256_zuswC.json’, ‘gabriel-de-soulages-the-awakened-portfolio-store.jpg?1636762065.json’, ‘20180416113856_SltEC.json’, ‘20180314105720_AMdmN.json’, ‘ccfe4786205588aed426f4d7a4caf075.json’, ‘heather-lenefsky-watson.jpg?1491346755.json’, ‘20180206225731_RayZJ.json’, ‘20190722155111_CeFdG.json’, ’01a46061223d0611013eaf70fe07bf.json’, ‘20190901125552_L2RkP.json’, ‘elise-weber-davidcatczesmilitaryportrait.jpg?1639691734.json’, ‘20190828124418_H555C.json’, ‘2021-06-18 22.33.01 2598847460357863558_13580129163.json’, ‘20171220210728_JBscT.json’, ‘d5beb886959f53f1acc2b90518cc7a2b–oeuvres-d-art-lovers-art.json’, ‘brx-gibson-e89918e7-df62-4d96-b93d-a6a625a2a417.jpg?1639564697.json’, ‘20180128104725_JLVsw.json’, ’01e3c5611a87d711013eaf7063c73d.json’, ‘cedf5c64570749.5ad6b67e30c9e.json’, ‘danji-isthmus-jake.jpg?1596616494.json’, ‘d65305188b95f34861763a5481926a76.json’, ‘cat111.json’, ‘20180929110853_VF22Y.json’, ‘izzie-s-spook-halloween-shitty-kitty-cropped.jpg?1618091573.json’, ‘elodie-ufarte-273424971-10228230066599475-2475901375400276753-n.jpg?1648051605.json’, ‘20181120115838_n4cNT.json’, ‘flame-born-asset.jpg?1597553140.json’, ‘20181229114748_RhHfl.json’, ‘20180314105414_wHfkU.json’, ‘20190228100812_QeRir.json’, ‘2021-08-27 21.15.27 2649542720297947942_1390548623.json’, ‘e-lynx-lin-laomeow.jpg?1528950390.json’, ‘20180315112301_EAwyR.json’, ‘2021-08-17 14.03.37 2642077612677952659_13580129163.json’, ‘20170930122045_ktSFB.json’, ‘fc03c9c99e41438bbee2c5e06789d19c.json’, ‘20180314110325_UAPRs.json’, ‘jello-jarabe-asset.jpg?1625588268.json’, ‘don-backos-maccat-web.jpg?1581969026.json’, ‘jenny-thalheim-01-januar-s.jpg?1641998461.json’, ‘elodie-ufarte-simba.jpg?1577569436.json’, ‘f51e6590974101.5e25d07463011.json’, ‘20190905114316_KNsaV.json’, ‘desiree-gaal-floofgoauch1.jpg?1560715214.json’, ‘20191110101612_tjimz.json’, ‘20170903125508_tZWuQ.json’, ‘francesca-d-angelo-customcatsticker-thumbnail2.jpg?1647288335.json’, ‘2021-07-07 20.37.15 2612559936702165833_13580129163.json’, ’01c05b5f425dc3a801215aa07d0285.json’, ’01ca2ibpjlwv36nyzmluew3232.json’, ‘20181127103321_Hi4ne.json’, ‘claire-gary-logan-copy.jpg?1605318423.json’, ’01e6ed5e44abc6a80120a895431548.json’, ‘20180130224045_2F3YB.json’, ‘jan-ladziansky-x-img-1521569182053.jpg?1565635992.json’, ‘20190722155111_e4tXs.json’, ‘20190106110418_JNzwE.json’, ‘carmen-chermenschi-cat-portrait-in-grey-toned-paper.jpg?1590388877.json’, ‘jacob-smith-rc05-lord-jethro-preston-coon-frameless.jpg?1572371873.json’, ‘jacob-smith-rc07-princess-chione-frameless.jpg?1572451968.json’, ‘elisabeth-aarebrot-madsen-sotpotet-mini.jpg?1600787602.json’, ‘20190722154942_EnFvf.json’, ‘christos-lytras-oriental-kitten-lowres.jpg?1625940596.json’, ‘20191110112522_CkdRn.json’, ‘2021-08-30 20.57.32 2651708029360428690_1390548623.json’, ‘disastrata-art-smokey.jpg?1524388865.json’, ‘brooke-minnie-final.jpg?1612294998.json’, ’01a92460c1703c11013f4720d3498a.json’, ‘jana-van-der-beucken-cat.jpg?1520640301.json’, ‘Illustration_Cheschire_Cat.jpg?1399434312.json’, ‘elen-galteland-akvarell-pus.jpg?1430579603.json’, ‘damien-mcauley-smudge.jpg?1655755636.json’, ‘20180601181502_jdirw.json’, ‘c492e915d8f3559f73ca34dcdc13d060.json’, ‘jacob-smith-rc01-sir-claudius-tunabreath-frameless.jpg?1572291294.json’, ‘20181220105351_3ktEt.json’, ‘glint-in-the-dark-cat.jpg?1638285025.json’, ‘eloise-girard-a2a316bc-8e1a-470c-adde-8ef6a602853a.jpg?1610559780.json’, ‘20170818095027_jz4Hn.json’, ‘20190228100812_iAaEr.json’, ‘20181231100723_VwmJ3.json’, ‘dbbeb6f8ddc70db570659bb92c50eb07.json’, ‘20190108110120_25nFz.json’, ‘declan-norris-gordan.jpg?1516681215.json’, ‘20170701105848_mVGZ2.json’, ‘20171006094227_v42eQ.json’, ‘dingzhong-hu-final-resize.jpg?1559842454.json’, ‘d0049bd2e3e3b608e0054881a15559f6.json’, ‘20180929110853_zNxwr.json’, ‘20190722154942_Cumxs.json’, ‘2021-06-18 20.35.12 2598788158049128636_1390548623.json’, ‘d57369c7ecd3ed6e164a2323f4adb8f5.json’, ‘20180702112109_Ll5TV.json’, ‘heather-lenefsky-mija.jpg?1491345767.json’, ‘f0f1c4129589095.616e7d1755f34.json’, ‘clay-nexus-1c66b609-4432-447f-8652-cbb935318248.jpg?1651002256.json’, ’01a5555f425dbda80120a8219a6823.json’, ‘20190228100940_hwecL.json’, ’01a17561223d1c11013eaf70096447.json’, ‘c890257499eafd32581a69a7931917b0.json’, ‘cornelia-jurka-katze2.jpg?1614430534.json’, ‘20180314110014_TCNr2.json’, ‘20180314105618_F8Pfm.json’, ‘20190722154942_xiwJc.json’, ‘20191019101550_MZy8V.json’, ‘daniela-ionela-firicel-x-img-1644408924792.jpg?1644420143.json’, ‘inta-antunes-caty1.jpg?1642157287.json’, ‘20170701105905_G2QL8.json’, ‘20180314105919_hmf2G.json’, ‘carlos-gato-acuarela.jpg?1642440481.json’, ‘20170710104801_Ljh3x.json’, ‘20181229114748_iktuN.json’, ‘d77df88fc48f4fce650edcc0dc30e833.json’, ‘20180128120029_Yjath.json’, ‘20190828124418_4AfGf.json’, ’01bba8611a87d611013eaf70e75fd8.json’, ‘20170710104636_vBtuH.json’, ‘echelle-illustration-2021-pidge.jpg?1648493808.json’, ‘iago-santos-lion-the-cat.jpg?1578879077.json’, ‘20180416114036_VdMFc.json’, ‘20181127103217_X4tdN.json’, ’01abygkhvgcmcuf3n0mm4l3638.json’, ‘inna-stefanova-k.jpg?1587030397.json’, ‘20190228100940_Rzauf.json’, ‘2021-06-09 19.46.42 2592240765862191808_1390548623.json’, ‘20171126092707_ShwkN.json’, ‘20190828124444_janTA.json’, ‘cade88415df9ada5336bcb9b7f4eb0dc.json’, ‘e24ab6e34fc28af033019f122fadd626.json’, ‘20180314105531_yR2hU.json’, ‘20190108110120_PZrK4.json’, ‘20180314105542_J2aQH.json’, ‘20181231100723_yLzNG.json’, ’01aace5fe4956f11013fdcc7348313.json’, ‘20180314110332_Srnde.json’, ‘20180314105740_ScajU.json’, ‘20180315112305_HcNVR.json’, ‘f316cf915bb3d9e4c9c703d6d15bdbce.json’, ‘connor-6fa8cdd8-bc8f-484c-9719-171aaee4db53.jpg?1643634322.json’, ‘ff2048adaac212ad155de0526636c4b5.json’, ‘ines-moro-monsieur-le-chat-30×40-petit.jpg?1575306045.json’, ‘20171114114641_hjVS5.json’, ‘helen-aimee-buttons.jpg?1589742917.json’, ‘20191110101641_NNdix.json’, ‘jay-dyjur-pet-portrait-speedpaint-1-smol.jpg?1620096718.json’, ’01aa7d5fb90c4d11013fdcc73755cc.json’, ‘cati-fornia-christmas-watercolor-cat-portrait-for-a-tabby-friend.jpg?1547170855.json’, ’01dcdd611a87d611013f47206818b2.json’, ’01d55860c8906c11013eaf70c51385.json’, ‘2021-07-16 20.12.22 2619070391598998847_1390548623.json’, ‘20170818094757_2wnW3.json’, ‘20171114114552_VuRzU.json’, ‘elen-panter-de2ruu8-7a09e66a-f823-484b-8e3a-37529022a2f4.jpg?1619338218.json’, ‘20180314105729_wLny4.json’, ‘e7e5e864570749.5ad6b67e308bf.json’, ‘ines-moro-grey9.jpg?1574342463.json’, ‘20190722155111_TxASk.json’, ‘20180416112933_ksujV.json’, ‘20171126092657_vzYZX.json’, ‘20190905114316_ezVhk.json’, ‘darina-.jpg?1655367267.json’, ’emily-guerra-image20220127103805.jpg?1643301776.json’, ‘cati-fornia-retro-cartoon-style-pet-portrait-for-a-tabby-cat-friend.jpg?1539268448.json’, ‘20190905114316_XGtTv.json’, ‘20180314110022_NzfWa.json’, ’01ab485fb90c4b11013ee04d5092bf.json’, ‘ian-tan-cat-color-v1-2000px.jpg?1653201355.json’, ‘20190315115327_Jt58G.json’, ‘20170804103523_Gm3LQ.json’, ‘helen-aimee-casper-web.jpg?1646414999.json’, ‘20181127103321_4rP5l.json’, ‘20180314105610_ZhrXu.json’, ‘f928d8afbbf26967e1c8288ef8d30b02.json’, ‘cati-fornia-halloween-style-portrait-for-our-tuxedo-cat-friend-by-catifornia.jpg?1541203714.json’, ’01d44260c8906d11013eaf70093e18.json’, ‘20190228100940_nZLCh.json’, ‘corelle-vairel-kithy.jpg?1606233424.json’, ‘20190227222259_ZZea4.json’, ‘20191110112536_acN8V.json’, ‘doofish-kitty-cat-1.jpg?1652279655.json’, ‘jenny-lynn-jenny-lynn-20210111-015213.jpg?1610905672.json’, ‘20191110112536_ATG4m.json’, ‘hoon-kim-hoon-kim-1.jpg?1647856074.json’, ‘20190106110710_rlRM5.json’, ‘daniel-cordobes-karin-fondo-rojo.jpg?1569791269.json’, ‘20171126091525_sZ5ah.json’, ‘20190106110710_xJyCN.json’, ‘20181220105351_QCcaV.json’, ‘20171210122458_y3uRQ.json’, ‘20171001122914_2VQEK.json’, ‘20190930113355_L5KFx.json’, ‘fb2d1ed3c8b9fa2a52fdd9822b6eaa31.json’, ‘20190901125552_EUteU.json’, ‘izzie-s-spaghetti-cat-kit-cropped.jpg?1618091352.json’, ‘f5d59d6e04788cd7afa41c5a71c3540d.json’, ‘20190905114316_ARTA8.json’, ’01ac335fb39b6011013fdcc71ea6b1.json’, ‘20180416112908_YWee3.json’, ‘elodie-ufarte-chat-portrait.jpg?1640184123.json’, ‘2021-08-03 20.50.51 2632135725534163778_1390548623.json’, ‘20190930113355_hvWEY.json’, ‘20171030114402_atESJ.json’, ‘edvard-kim-52106e61-c429-4ae3-8316-68cf3012d3cc.jpg?1643162415.json’, ‘20170710115126_e5Cct.json’, ‘20181229114748_XNakF.json’, ‘jayme-trevino-img-4528.jpg?1593225663.json’, ’01e14661c7256111013e8cd06e9395.json’, ‘20181231100723_QZxje.json’, ‘d5d3d8115269913.604b06272947e.json’, ‘20180314110303_tReTa.json’, ‘elodie-ufarte-24741407-9c1a-4422-99f7-c0eb7fcac2eb.jpg?1613066280.json’, ‘20180702112109_zWPf3.json’, ‘dia-arizaga-josefranciscokofi.jpg?1641927433.json’, ‘20190930113355_3KP2f.json’, ’01ac3c57fda04ea84a0e282b0d5387.json’, ’01a60361223d1b11013eaf707b80f6.json’, ‘20180328113212_V2cZG.json’, ‘20191129110230_aMGHY.json’, ‘20180314105601_Tfwnt.json’, ‘f4675f147011829.62bade87b9e83.json’, ‘charlie-corrigan-charlie-corrigan-cat.jpg?1606404753.json’, ‘e7b66068446944078dd5496e01fb2ce6.json’, ‘20191129110230_3TzEC.json’, ’01b5dnsodpcp83lhmcbwss3237.json’, ‘elisabeth-aarebrot-madsen-echo-mini.jpg?1598698241.json’, ‘20180314105701_QT8fK.json’, ‘20190807153620_CtNwW.json’, ‘gracie-donovan-asset.jpg?1657239827.json’, ‘e9cdc6115269913.604b06272778b.json’, ‘20180328113209_khf4W.json’, ‘jennifer-penderis-pepper-done-2.jpg?1625913639.json’, ‘20180128104709_MXfzs.json’, ‘20190227222300_FkUrS.json’, ‘gabby-correia-muggleborn-sphynx-portrait-final-smaller.jpg?1546748931.json’, ‘20171114114618_RmSuH.json’, ‘d5b813432d41d7e6f3f349e74c2f15f4.json’, ‘casseyart-20210827-081528.jpg?1631339110.json’, ‘2021-08-17 14.03.37 2642077612334042707_13580129163.json’, ‘iselin-kristin-lillealter-senku-and-anouck.jpg?1605314406.json’, ‘c90d035e66d1d2fb1cb94d95372c1da3.json’, ‘james-hebert-asset.jpg?1602091954.json’, ‘gabriella-di-gianfrancesco-regalo-insta-4.jpg?1631091146.json’, ’01c3b661554f1711013f22cf649175.json’, ‘corinna-marin-jasper-10×10.jpg?1593562415.json’, ‘20190807152043_hKZv2.json’, ‘20180207100305_nQnwm.json’, ‘20180314105334_w3xUW.json’, ‘chloe-carter-bleu-snowflake6.jpg?1582327024.json’, ‘igor-pisarenko-catty.jpg?1590502501.json’, ‘20180315112310_lVGVa.json’, ‘2021-08-18 21.26.38 2643025370125055992_1390548623.json’, ‘2021-05-21 19.46.25 2578469884547761720_1390548623.json’, ‘20181220105351_HuMWQ.json’, ’01d2be5f8935f311013f31102839dc.json’, ‘indah-rastika-anthro-kucing-gangster.jpg?1517694776.json’, ‘20180314105939_3mLWh.json’, ‘iskren-krastev-tabby-broun-3.jpg?1617628023.json’, ‘dave-freeman-weeble-portrait-by-jellybit-dakieqa.jpg?1522688918.json’, ‘20180315045349_yxipt.json’, ‘20190905114316_ZGUxx.json’, ‘20190228100940_x3EVZ.json’, ‘izzie-s-shitty-kitty-karen-v2.jpg?1618092014.json’, ‘ildy-izso-sushi047-copy.jpg?1649899109.json’, ‘20180314105957_F4jiV.json’, ‘20170930122022_uFWCG.json’, ‘20171114114543_3vCRE.json’, ‘2021-08-17 14.03.37 2642077612334004550_13580129163.json’, ‘dominika-olszewski-dominika-olszewski-9d09f31e-8d89-42e8-a3e1-09239614a1b4.jpg?1655135500.json’, ‘chen-the-noblewoman-30×40-3963867594919-21053-final.jpg?1632822783.json’, ‘20190722154942_8LvVu.json’, ‘jen-maynulet-cat.jpg?1504556273.json’, ‘20190828124444_rcMu2.json’, ‘20180416112930_h8HFS.json’, ‘20180416114031_sQn5J.json’, ‘20180130224011_XjVhB.json’, ‘hope-duston-img-5293.jpg?1587680246.json’, ‘cassandra-richards-dudes-cat.jpg?1606004167.json’, ‘20171006094154_UFBcx.json’, ‘01038d5ec0b443a801214814c51dab.json’, ‘jacob-smith-rc014-duchess-lucina-von-birdsbane-frameless.jpg?1634050988.json’, ‘brooke-penny-final.jpg?1621909726.json’, ‘ef1c6164250273.5acc56d5bb92c.json’, ‘20190108110120_xLSFV.json’, ‘ec1d25362d1bba5006c6ae296f94ba34.json’, ‘2021-08-17 14.03.37 2642077612275386025_13580129163.json’, ‘20181127103217_SNlGh.json’, ‘chen-15944-w.jpg?1642601285.json’, ‘20190228100812_tVGVf.json’, ‘20181127103217_rXTPL.json’, ’01a59260f4f9bc11013f47205f4833.json’, ‘20190106110710_LWtSt.json’, ‘d5b966859c94a198b5d0b269a012e1ad–nyan-cat-hug-me.json’, ‘cami-cuibus-ninja.jpg?1613423747.json’, ‘eric-lynx-lin-yrlin-110818.jpg?1542851216.json’, ‘jade-venables-soul3.jpg?1553173620.json’, ‘20181220105351_8hCve.json’, ‘eric-lynx-lin-wayofthedragon01.jpg?1543972330.json’, ‘2021-06-17 19.41.07 2598036160219521508_1390548623.json’, ‘ilaria-gioli-jpg.jpg?1628622344.json’, ‘20191110112717_FTu5x.json’, ‘butter-h-asset.jpg?1624456865.json’, ’01accb5ef1e564a801215aa0131c5d.json’, ‘20171030114507_QrLHh.json’, ‘2021-08-12 21.29.19 2638678068919901769_1390548623.json’, ‘edward-chan-tze-ming-asset.jpg?1644924190.json’, ‘20180128104736_HFxQd.json’, ‘ines-o-neill-ines-o-neill-artstation-thumbnails-template-02-0010-03.jpg?1622132521.json’, ‘cassie-lyons-untitled13.jpg?1652281710.json’, ‘jacob-smith-rc20-earl-cosimo-alessio-da-vigo-frameless.jpg?1634051262.json’, ‘20180328113737_a8KVV.json’, ‘gem-scarlet-picsart-08-22-06-59-03.jpg?1534958027.json’, ‘20190722155111_Zu8ud.json’, ‘gabriel-belschansky-sem-titulo-1.jpg?1632812312.json’, ‘jaqueline-stahl-creamy-crop.jpg?1613434858.json’, ‘diana-kubeckova-max-ragdoll-portrait.jpg?1616525425.json’, ‘heidi-noirot-victorian-ninine-rog4.jpg?1608226213.json’, ‘20180416113901_kTZwn.json’, ’01a899606b191611013e87f4701fa9.json’, ‘fabienne-zuijdgeest-271092289-448709029988013-1845875441442583693-n.jpg?1641910791.json’, ‘2021-08-17 14.03.37 2642077612686258616_13580129163.json’, ‘2021-07-21 20.11.56 2622694050867776171_1390548623.json’, ‘ilinca-mitchell-fv-jaqcui-cat-copy-final-copysm2.jpg?1621894800.json’, ‘2021-08-11 21.08.48 2637942962248977618_1390548623.json’, ‘fb47ef66dcb244b6c2cce452346c7eef.json’, ’01a666554bda13000001bf7246d0f6.json’, ‘20170818095018_TewJV.json’, ‘20180207100258_ZKMhw.json’, ‘20180328113723_yxmHM.json’, ‘2021-07-14 20.33.53 2617631665895402450_1390548623.json’, ‘horst-peter-bittmann-fleurstudy-artstation.jpg?1609453807.json’, ‘c1ecad544195b0b42474085d7d2fc6a1.json’, ’01a81d61223d1f11013f47203e0c4f.json’, ‘20191129110230_UNfwN.json’, ’01a4da61223d0611013eaf7079b3d5.json’, ‘20190828124418_iHNRU.json’, ‘20171114114511_CfSjr.json’]

结果图为:

所有代码如下:


from os import listdir



path = ‘./cat_valid/CAT_06/’



filelist = listdir(path)



filelist1=[]



for i in range(0,len(filelist)):



index = filelist[i].split(“.”)[-1]



if index==’json’:



filelist1.append(filelist[i])



print(filelist1)

登录帐号的可以直接复制下面内容:

from os import listdir
path = './cat_valid/CAT_06/'
filelist = listdir(path)
filelist1=[]
for i in range(0,len(filelist)):
    index = filelist[i].split(".")[-1]
    if index=='json':
        filelist1.append(filelist[i])
print(filelist1)



版权声明:本文为m0_54188335原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。