小编Fir*_*ras的帖子

循环浏览文件夹中的文件

在编程方面我很新,并开始学习python.

我想要做的是为游戏重新塑造精灵,我会得到原始颜色,然后是他们要变成什么颜色.每个精灵都有20到60个角度,所以循环浏览每个颜色的文件夹中的每一个都可能是我的选择.我的代码如此;

import media
import sys
import os.path

original_colors = str(raw_input('Please enter the original RGB component, separated ONLY by a single space: '))
new_colors = str(raw_input('Please insert the new RGB component, separated ONLY by a single space: '))
original_list = original_colors.split(' ')
new_list = new_colors.split(' ')
folder = 'C:\Users\Spriting\blue'
if original_colors == 'quit' or new_colors == 'quit':
    sys.exit(0)
else:
    while 1:
        for filename in os.listdir (folder):
            for pix in filename:
                if (media.get_red(pix) == int(original_list[0])) and (media.get_green(pix) == int(original_list[1])) and \ …
Run Code Online (Sandbox Code Playgroud)

python loops file

34
推荐指数
3
解决办法
6万
查看次数

标签 统计

file ×1

loops ×1

python ×1