[Tutor] os.walk() with multiple paths
Alan Gauld
alan.gauld at yahoo.co.uk
Tue May 22 19:09:01 EDT 2018
On 22/05/18 20:06, Pi wrote:
> works fine, but only for one path. And I need to use more than one path.
> With one path given works great:
>
> >>> find_db("/dbbs")
> ['april.db, /dbbs/analysis/april.db', 'important.sqlite,
> /dbbs/temp/important.sqlite', 'march.db, /dbbs/analysis/march.db',
> 'weelky.sqlite3, /dbbs/analysis/queue/weelky.sqlite3']
>
>
> But with more paths gives files only for last path given:
>
> >>> find_db("/home/user/Desktop, /dbbs")
Note that split() will split based on whitespace so the comma
will be included in the first path. That probably renders it
invalid and so you don't get any results.
Either split by , or use strip() to remove it.
HTH
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list