嘿,我是相當新的python,我目前正在大學學習Jython。所以請原諒我的無知。自動撥號從字典
基本上我想要做的是使用用戶選擇的圖像(很容易)創建一個「漫畫書」風格的圖片,但因爲創建的圖片的數量是一個變量,我已經使用了一個字典,並指定了鍵for函數中的每個循環。但是我想在另一個循環中再次回憶它們。 (另,我知道那裏有可能是在我的代碼了一些錯誤,我只是把它最多給你一個想法
def comicStrip():
picture={}
totalWidth=0
totalHeight=0
pixelCount=0
loopCounter=0
pictureCount=requestInteger("How many pictures do you want in the comic strip?(1-4)")
while pictureCount <1 or pictureCount >4:
pictureCount=requestInteger("How many pictures do you want in the comic strip?(1-4)")
for p in range(1,pictureCount+1):
picture[p]=makePicture(pickAFile())
width[p]=getWidth(picture[p])
height[p]=getHeight[p]
totalWidth=totalWidth+width[p]
height=getHeight(picture[p])
if height > totalHeight:
totalHeight=height
cStrip=makeEmptyPicture(totalWidth, totalHeight)
while loopCounter < pictureCount:
for targetX in range(0,p1Width):
sourceY=0
for targetY in range(0,p1Height):
color = getColor(getPixel(picture1,sourceX,sourceY))
setColor(getPixel(cStrip,targetX,targetY),color)
sourceY=sourceY+1
sourceX=sourceX+1
addRectFilled(cStrip,0,0,p1Width,20,white)
addRect(cStrip,0,0,p1Width,20)
addRect(cStrip,0,0,p1Width,p1Height)
caption=requestString("Enter the caption for this picture.")
addText(cStrip,1,19,str(caption))
您可能會發現張貼,一旦你得到的東西努力http://codereview.stackexchange.com/有用的反饋。 – YXD
謝謝你,我一定會看看。 –