Bonjours, j'ai un probleme avec textMate pour ecrire des fichiers en python
lorsque je cree une nouveau fichier python : File/New from template/Python/Python script un nouveau fichier apparait
#!/usr/bin/env python
# encoding: utf-8
"""
untitled.py
Created by steven athouel on 2014-08-28.
Copyright (c) 2014 __MyCompanyName__. All rights reserved.
"""
import sys
import os
def main():
pass
if __name__ == '__main__':
main()
tout d'abord je ne sais pas trop ou ecrire mon code je suppose que cela doit etre sous le main() comme dans le tuto sur le langage C.
lorsque je lance mon programme avec un simple print sa fonctionne mais lorsque j'utilise un input un message d'erreur s'affiche
"
hello
Error in sys.excepthook:
Traceback (most recent call last):
File "/Applications/TextMate.app/Contents/SharedSupport/Bundles/Python.tmbundle/Support/sitecustomize.py", line 44, in tm_excepthook
io = fdopen(error_fd, 'wb', 0)
OSError: [Errno 9] Bad file descriptor
Original exception was:
Traceback (most recent call last):
File "untitled", line 21, in <module>
annee = input("annee ?")
EOFError: EOF when reading a line
annee ?"
correspondant a ce code
#!/usr/bin/env python
# encoding: utf-8
"""
untitled.py
Created by steven athouel on 2014-08-28.
Copyright (c) 2014 __MyCompanyName__. All rights reserved.
"""
import sys
import os
def main():
pass
if __name__ == '__main__':
main()
print("hello")
annee = input("annee ?")
#!/usr/bin/env python
# encoding: utf-8
print("hello")
annee = int(input("annee ?"))
annee += 2
print(annee)
input("Pause appuie sur une touche pour finir le programme")
j'ai converti annee en int pour le manipuler. je lui ajoute 2. j'affiche. pas de def ou de main ici.
Ecriture sur fichier via TextMate
× Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
× Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
j'ai converti annee en int pour le manipuler. je lui ajoute 2. j'affiche. pas de def ou de main ici.