Question

Je suis un débutant en python et je suis en train d'utiliser un numéro octal dans mon script, mais quand je l'essaye, il me retourne cette erreur:

>>> a = 010
SyntaxError: invalid token (<pyshell#0>, line 1)
>>> 01
SyntaxError: invalid token (<pyshell#1>, line 1)

Il y a quelque chose de mal avec mon code? J'utilise python3 (et la lecture d'un python 2.2 livre)

Était-ce utile?

La solution

Essayez 0o10, peut être à cause de python 3 ou pyshell lui-même.

PEP dit,

  

littéraux octal doit être spécifié   avec l'un des principaux « 0o » ou « 0O » au lieu de   "0";

http://www.python.org/dev/peps/pep-3127 /

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top