IPB

Bienvenue invité ( Connexion | Inscription )

[ En ligne ] · Standard · Linéaire+

> Momo Se Remet à La "programmation", Sponsorised by O'Reilly

momo
post 21/02/2004 1:21
Message #1


lvl1 male rogue St=1 Dex=5 Int=17 Wi=5 Ch=0
****

Groupe : Modérateurs
Messages : 1,730
Inscrit le : 16/05/2002 23:00
Lieu : .gif
Membre no. 12



CODE
from Tkinter import *
def printit(event):
   words=dict([("..--..","?"),("--..--",","),(".-.-.-","."),("----.","9"),("---..","8"),
           ("--...","7"), ("-....","6"), (".....","5"), ("....-","4"), ("...--","3"),
           ("..---","2"), (".----","1"), ("-----","0"), ("--..","z"), ("-.--","y"),
           ("-..-","x"), ("...-","v"), ("--.-","q"), (".---","j"), ("....","h"),
           ("..-.","f"), ("-.-.","c"), ("-...","b"), (".--.","p"), ("..-", "u"), ("...","s"),
           (".-.","r"), ("---","o"), ("-.-","k"), ("--.","g"), ("-..","d"),
           ("-.","n"), ("..","i"), ("--","m"), (".-","a"), (".","e"), ("-","t"),
           (".-..","l"), (".--","w")])
   fichier=unicode(ent.get())
   sfichier=""
   caractere="0"
   counter=0
   while caractere<>"":
       if counter<int(len(fichier)):
           caractere=fichier[counter]
       else:
           caractere=""
       counter=counter+1
       chaine =""
       while ( caractere=="." or caractere=="-"):
           chaine=chaine+caractere
           if counter<int(len(fichier)):
               caractere=fichier[counter]
           else:
               caractere=""
           counter=counter+1
       if words.has_key(chaine):
           schaine=words[chaine]
           chaine=""
           caractere="."
           sfichier=sfichier+unicode(schaine)
       else:
           sfichier=sfichier+unicode(chaine)
           chaine=""

       if (caractere=="." or caractere=="-"):
           caractere="0"
       else:
           sfichier=sfichier+unicode(caractere)
   lab.configure(text=unicode(sfichier))

fen=Tk()
ent=Entry(fen)
lab=Label(fen)
ent.bind("<Return>",printit)
ent.pack()
lab.pack()
fen.mainloop()

Ben ouais, m'ennuyant, je me suis acheté "Apprendre à programmer avec Python" et "Python Précis et concis" (non, pas seulement pour avoir le sadisme de mettre le python en présence de la mangouste wink.gif).
Et comme j'ai toujours ce programme @ la con de decodage de code Morse qui traine ...


--------------------
Natural evolution insists that we are apes; artificial evolution insists that we are machines with an attitude.
Kevin Kelly - Out of control
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
 
Reply to this topicStart new topicStart Poll
Réponse(s)
momo
post 02/03/2004 18:25
Message #2


lvl1 male rogue St=1 Dex=5 Int=17 Wi=5 Ch=0
****

Groupe : Modérateurs
Messages : 1,730
Inscrit le : 16/05/2002 23:00
Lieu : .gif
Membre no. 12



ça tombe bien, il y a un ou deux liens qui trainenet dans le sujet à ce propos ... smile.gif


--------------------
Natural evolution insists that we are apes; artificial evolution insists that we are machines with an attitude.
Kevin Kelly - Out of control
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Posts in this topic


Reply to this topicTopic OptionsStart new topic
1 utilisateur(s) sur ce sujet (1 invité(s) et 0 utilisateur(s) anonyme(s))
0 membre(s) :
 

Version bas débit Nous sommes le : : 01/05/2024 15:03