我已经解决了这个问题:import sys
import cv2
import os
def main():
File_Lst =[]
plat = sys.platform
#print plat
if plat == 'win32': #for windows operating system
File_dir = "C:\\Users\\user\\Desktop\\fruit\\"
elif plat == 'linux2': # for linux
File_dir = "/host/Users/user/Desktop/fruit/"
for file in os.listdir(File_dir):
File_Lst.append(file)
print File_Lst
welcome_index = File_Lst.index('welcome.jpg')
welcome_str = File_Lst[welcome_index]
orange_index = File_Lst.index('orange.jpg')
orange_str = File_Lst[orange_index]
apple_index = File_Lst.index('apple.jpg')
apple_str = File_Lst[apple_index]
banana_index = File_Lst.index('banana.jpg')
banana_str &#