Python os.listdir方法代码示例
在下文中一共展示了Python os.listdir方法的代码示例,这些例子默认根据受欢迎程度排序。
示例1: help
# 需要导入模块: import os [as 别名] # 或者: from os import listdir [as 别名] def help(): print(""" Usage: python weather-icons.py options options: loop image-file.png example: weather-icons.py loop weather-icons.py clear-day.png try one of the files from this list: {} """.format(', '.join(os.listdir(folder_path))))
示例2: loop
# 需要导入模块: import os [as 别名] # 或者: from os import listdir [as 别名] def loop(): print('Looping through all images in folder {}\n' 'CRL+C to skip image'.format(folder_path)) try: for img_file in os.listdir(folder_path): if img_file.endswith(icon_extension): print('Drawing image: {}'.format(folder_path + img_file)) img = Image.open(folder_path + img_file) draw_animation(img) else: print('Not using this file, might be not an image: {}'.format(img_file)) except KeyboardInterrupt: unicorn.off() unicorn.off()