废话不多说,直接上代码,取得当前目录:
path = os.path.dirname(sys.argv[0])
遍历当前目录:
def traveldir(root_dir):
for dir_or_file in os.listdir(root_dir):
path = os.path.join(root_dir, dir_or_file)
print path
if os.path.isdir(path):
traveldir(path)
csv文件读写:
import csv
csv_data = csv.reader(open("filename.csv"))
for line in csv_data:
print line