Skip to content
Snippets Groups Projects
Commit a64189d0 authored by Almohamed Alsadou Fatima's avatar Almohamed Alsadou Fatima
Browse files

fonction lecture fichier

parent 408ad0bf
Branches
No related tags found
No related merge requests found
......@@ -25,6 +25,8 @@ and methods
from typing import TypeVar
T = TypeVar('T')
class ApQueueEmptyError(Exception):
"""
Exception for empty stacks
......@@ -95,7 +97,7 @@ class ApQueue():
return the string representation of this queue.
"""
return ApQueue.ARROW + \
"|".join(str(el) for el in self.__content) + \
"|".join(str(el) for el in self.__content[::-1]) + \
ApQueue.ARROW
......
......@@ -81,7 +81,7 @@ class Card(object):
$$$
"""
return f"{self.value}/{self.color}"
return f"{self.value} of {self.color}"
def compare(self, card: Card) -> int:
......
......@@ -11,7 +11,7 @@
:last revision: 2024, march.
"""
from card import Card
from card import *
from apqueue import *
from apstack import *
......@@ -37,7 +37,11 @@ def distribute(n_card: int) -> tuple[ApQueue, ApQueue]:
$$$ isinstance(carte, Card)
True
"""
...
files_cartes=ApQueue()
liste=Card.deck(n_card)
for i in range(len(liste)):
files_cartes.enqueue(liste[i])
return files_cartes
def gather_stack(main: ApQueue, pile: ApStack) -> None:
"""
......
from PIL import Image
def lecture_fichier(fichier:str)->list:
liste=[]
with open(fichier,'r')as f:
for line in f:
liste.append(line[0:-1])
res=[]
for elt in liste:
res.append(elt.split(';'))
return res
imagef=Image.open('images/images/galets.png')
def conversionpx_image(image:str,fichier:str)->Image:
"""
convertir un fichier de px en image
Précondition :
Exemple(s) :
$$$
"""
liste=lecture_fichier(fichier)
for (x,y) in (250,250):
for i in range (0,int(liste),3):
imagef.putpixel((x,y),(liste[i],liste[i+1],liste[i+2]))
imagef.show()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment