http://docs.python.jp/3/tutorial/stdlib.html
os
モジュールで定義されている名前import os
for name in dir(os):
print(name)
...(snip)...
abort
access
altsep
chdir
chflags
chmod
chown
chroot
close
...(snip)...
os.chdir
,
os.system
, os.getcwd
import os
os.chdir('/tmp')
print(os.getcwd())
os.system('mkdir test')
os.chdir('test')
print(os.getcwd())
/private/tmp
/private/tmp/test
/tmp
じゃなくて
/private/tmp
なんだろ。glob
import os
import glob
for filename in glob.glob('*.txt'):
print(filename)
print()
"ls *.txt") os.system(
datafile.txt
input.txt
test.txt
datafile.txt input.txt test.txt
sys.argv
import sys
= 0
n for s in sys.argv:
print(n, s)
+= 1 n
$ python3 test.py foo baa hello
0 test.py
1 foo
2 baa
3 hello