execfile
Rédigé par Paulo
Aucun commentaire
Classé dans : Python
![](data/images/python-logo.png)
Lecture d'un fichier sous la forme 'truc = machin':
- python2:
>>>execfile('/etc/os-release')
>>>print ID
centos
- python3:
>>> exec(open("/etc/os-release").read())
>>> print(VERSION_ID)
8
Voir aussi load_file:
source: https://qastack.fr/programming/436198/what-is-an-alternative-to-execfile-in-python-3