我在編程方面相當新,並且已經開始學習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 \
(media.get_blue(pix) == int(original_list[2])):
media.set_red(pix, new_list[0])
media.set_green(pix, new_list[1])
media.set_blue(pix, new_list[2])
media.save(pic)
,但我一直在路徑得到一個錯誤,並在PIX是一個字符串值(他們都是圖片)
任何幫助表示讚賞。
你可以顯示你收到的具體錯誤信息嗎? – perimosocordiae 2009-11-24 19:24:22
這是一個學校作業嗎?我在「媒體」模塊上從Google獲得的所有搜索結果似乎都表明它是...... – 2009-11-24 19:28:11