listdir
jmp
jeanmichel at sequans.com
Mon Sep 5 11:57:11 EDT 2016
On 09/05/2016 05:41 PM, Smith wrote:
> Il 05/09/2016 17:34, Rustom Mody ha scritto:
>> So what do you get when you replace the if-else with a simple:
>> print(file)
>
> a = input("search for files with the extension .py into directory: ")
> for file in os.listdir(a):
> if file.endswith(".py"):
> print(file)
>
>
> search for files with the extension .py into directory: /home/
> filepy.py
> tempo.py
> filescript.py
> ticker.py
> toolgen.py
> words.py
> m.py
> scrapingweb.py
> partitesnai.py
> pythonprova.py
> scraper.py
> snmp.py
> printreturn.py
> multiping.py
> scraping.py
> funzionipython.py
Is that what you're expecting ?
A slightly different version:
import glob, os
a = input("search for files with the extension .py into directory: ")
print glob.glob(os.path.join(a, '*.py'))
jm
More information about the Python-list
mailing list