List current directory content
from java.io import *
import os
# adapted from Java Almanac
currentDirectory = File(os.path.abspath(""))
li = dir.listFiles()
# pretty printing
for i in li: print i
dir.listFiles() will return an array (for the java engine).
Apparently you can treat an array as list, cool :lol:
p/s: yet to implement the filter as in the Java Almanac example.
update:
A little googling results in (modified from Python Cookbook):
from import import io
class ff(io.FilenameFilter):
def accept(self, dir, name):
if name.lower()[-4:] == jar: return 1
L = io.File(os.path.abspath("")).list(ff())
2 comments:
JS nye version ada ???
ha?? javascript nak read local file??
Post a Comment