since i'm new to python i decided to make a dice roll program and i have a problem. i have 2 folders in my program: dice roll, and dice. dice roll has dice inside of it. dice roll also has a python file called dice roll.py: from random import randint exec(open("./dice/DiceCrop.py").read(), globals()) print(randint(1,6))
the dice folder has a python file called DiceCrop.py the code for DiceCrop.py is:
`from PIL import Image
dice = Image.open("dice.png")
dice1 = dice.crop((0, 50, 65, 150)) dice1.save("one.png")
dice2 = dice.crop((64, 50, 131, 150)) dice2.save("two.png")
dice3 = dice.crop((130, 50, 196, 150)) dice3.save("three.png")
dice4 = dice.crop((196, 50, 262, 150)) dice4.save("four.png")
dice5 = dice.crop((262, 50, 328, 150)) dice5.save("five.png")
dice6 = dice.crop((328, 50, 394, 150)) dice6.save("six.png")`
the dice folder also has an image called dice.png. but when i run dice roll.py it says there is no such file as dice.png. i know why this happens but i don't know how to fix it. it happens because it opens in the dice roll folder and not the dice folder. how do i make it open in the dice folder and not the dice roll folder? error message
Aucun commentaire:
Enregistrer un commentaire