Why was .pyc file created? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

Why was .pyc file created?

I created a file KingKong.py: def KingKong(): print("Kingkong kingkong kingkong!") input("King?") print("Kong!") if __name__ == "__main__": print("Sorry") Then I executed Kong.py: import KingKong KingKong.KingKong() But why was KingKong.cpython-36.pyc created with text: 3 ļæ½ļæ½<[ļæ½ļæ½@sddļæ½Zedkredļæ½dS)cCstdļæ½tdļæ½tdļæ½dS)NzKingkong kingkong kingkong!zKing?zKong!)ļæ½printļæ½inputļæ½rrļæ½0/storage/emulated/0/S/Python_project/KingKong.pyļæ½KingKongsrļæ½__main__ZSorryN)rļæ½__name__rrrrrļæ½<module>s

4th Jul 2018, 5:02 PM
Seb TheS
Seb TheS - avatar
3 Respostas
+ 6
Python automatically compiles your script to compiled code, so called byte code, before running it. When a module is imported for the first time, or when the source is more recent than the current compiled file, a .pyc file containing the compiled code will usually be created in the same directory as the .py file. http://effbot.org/pyfaq/how-do-i-create-a-pyc-file.htm
4th Jul 2018, 5:14 PM
Agent
Agent - avatar
+ 1
.pyc file is created on the first run and contains a bytecode: https://docs.python.org/3.5/glossary.html#term-bytecode The structure of the bytecode may depend on interpreter used to run python code.
4th Jul 2018, 5:22 PM
Fitz
Fitz - avatar
+ 1
you can delete them no worries, they will spawn when needed
4th Jul 2018, 5:25 PM
Qwertiony
Qwertiony - avatar