• 代码
# -*- coding: utf-8 -*-
"""
Spyder Editor

This is a temporary script file.
"""

# 目录操作
# Load library
import os
import sys

# check the current system path
for path in sys.path:
print(path)


# check the root directory
root_dir = os.path.abspath('../') # '../' stands for folder beyond two
print(root_dir)


# append Github library to sys path for python searching
sys.path.append(root_dir)

# join path
my_path = os.path.join(root_dir,'my_test')

# 对齐打印
class_names = ['BG', 'person', 'bicycle', 'car', 'motorcycle', 'airplane',
'bus', 'train', 'truck', 'boat', 'traffic light',
'fire hydrant', 'stop sign', 'parking meter', 'bench', 'bird',
'cat', 'dog', 'horse', 'sheep', 'cow', 'elephant', 'bear',
'zebra', 'giraffe', 'backpack', 'umbrella', 'handbag', 'tie',
'suitcase', 'frisbee', 'skis', 'snowboard', 'sports ball',
'kite', 'baseball bat', 'baseball glove', 'skateboard',
'surfboard', 'tennis racket', 'bottle', 'wine glass', 'cup',
'fork', 'knife', 'spoon', 'bowl', 'banana', 'apple',
'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza',
'donut', 'cake', 'chair', 'couch', 'potted plant', 'bed',
'dining table', 'toilet', 'tv', 'laptop', 'mouse', 'remote',
'keyboard', 'cell phone', 'microwave', 'oven', 'toaster',
'sink', 'refrigerator', 'book', 'clock', 'vase', 'scissors',
'teddy bear', 'hair drier', 'toothbrush']

for idx, item in enumerate(class_names):
print('#%.2d is %s'%(idx,item))
  • 结果
# 目录操作
/home/bruceelau/anaconda3/envs/fcn/lib/python35.zip
/home/bruceelau/anaconda3/envs/fcn/lib/python3.5
/home/bruceelau/anaconda3/envs/fcn/lib/python3.5/plat-linux
/home/bruceelau/anaconda3/envs/fcn/lib/python3.5/lib-dynload
/home/bruceelau/anaconda3/envs/fcn/lib/python3.5/site-packages
/home/bruceelau/anaconda3/envs/fcn/lib/python3.5/site-packages/IPython/extensions
/home/bruceelau/.ipython
/home/bruceelau/Downloads/Github

# 对齐打印
#00 is BG
#01 is person
#02 is bicycle
#03 is car
#04 is motorcycle
#05 is airplane
#06 is bus
#07 is train
#08 is truck
#09 is boat
#10 is traffic light
#11 is fire hydrant
#12 is stop sign
#13 is parking meter
#14 is bench
#15 is bird
#16 is cat
#17 is dog
#18 is horse
#19 is sheep
#20 is cow
#21 is elephant
#22 is bear
#23 is zebra
#24 is giraffe
#25 is backpack
#26 is umbrella
#27 is handbag
#28 is tie
#29 is suitcase
#30 is frisbee
#31 is skis
#32 is snowboard
#33 is sports ball
#34 is kite
#35 is baseball bat
#36 is baseball glove
#37 is skateboard
#38 is surfboard
#39 is tennis racket
#40 is bottle
#41 is wine glass
#42 is cup
#43 is fork
#44 is knife
#45 is spoon
#46 is bowl
#47 is banana
#48 is apple
#49 is sandwich
#50 is orange
#51 is broccoli
#52 is carrot
#53 is hot dog
#54 is pizza
#55 is donut
#56 is cake
#57 is chair
#58 is couch
#59 is potted plant
#60 is bed
#61 is dining table
#62 is toilet
#63 is tv
#64 is laptop
#65 is mouse
#66 is remote
#67 is keyboard
#68 is cell phone
#69 is microwave
#70 is oven
#71 is toaster
#72 is sink
#73 is refrigerator
#74 is book
#75 is clock
#76 is vase
#77 is scissors
#78 is teddy bear
#79 is hair drier
#80 is toothbrush