Tsang, Edward1 wrote: > Let say I invoke the script in directory d, but I have abunch of > subdirectories under d. > > tpTcCTFTEST10/ tpTcCTFTESTTIGHT02/ tpTcTNLC14_2/ > tpTcTNLC6_5/ > > and each subdirectory contains a file tp_acc.1. I want to do some processing > to this file, but asking the user to click each folder and input the file > name is just too much work for them, how can I just display the files in the > subdirectories. Use the 'glob' module, which simulates '*' and '?' expansion of filenames: import glob filenames = glob.glob('tpTc*/tp_acc.1') 'filenames' will now contain a list of the files in the subdirectories. -Steve -- Steve Purcell, Pythangelist Get testing at http://pyunit.sourceforge.net/ Any opinions expressed herein are my own and not necessarily those of Yahoo
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4