#!/usr/bin/env pythonimport ostmpdir = r'c:temp'if tmpdir: os.chdir(tmpdir) cwd = os.getcwd() print cwd os.mkdir('example') os.chdir('example') cwd = os.getcwd() print cwd print os.listdir(cwd) fobj = open('test', 'w') fobj.write('foon') fobj.write('barn') fobj.close() print os.listdir(cwd) os.rename('test', 'filetest.txt') print os.listdir(cwd) path = os.path.join(cwd, os.listdir (cwd)[0]) print path print os.path.split(path) print os.path.splitext(os.path.basename(path)) fobj = open(path) for eachLine in fobj: print eachLine, fobj.close() os.remove(path) print os.listdir(cwd) os.chdir(os.pardir) os.rmdir('example')
Name (required)
email (will not be published) (required)
Website