-1

これが私のスクリプトです。

 import os

for dirname, dirnames, filenames in os.walk('.'):
# print path to all subdirectories first.
for subdirname in dirnames:
    print os.path.join(dirname, subdirname)

# print path to all filenames.
for filename in filenames:
    print os.path.join(dirname, filename)

# Advanced usage:
# editing the 'dirnames' list will stop os.walk() from recursing into there.
if '.git' in dirnames:
    # don't go into any .git directories.
    dirnames.remove('.git')

コマンドラインを使用しています:mac端末でpython -m SimpleHTTPServer 8000。今、ブラウザから上記のスクリプトを実行したいと思います。単純に機能せず、ファイルの内容を出力するだけです。それを実行する方法 (PHP ファイルが実行され、Apache Web サーバーでディレクトリを一覧表示する方法)。

4

1 に答える 1