Inleiding tot Python
- Previous Page Introductie tot Python
- Next Page Python Syntax
Python Installatie
Veel PC's en Mac's hebben al Python geïnstalleerd.
Om te controleren of Python is geïnstalleerd op een Windows PC, zoek dan in het startbalk naar Python of voer de volgende opdracht uit in de opdrachtprompt (cmd.exe):
C:\Gebruikers\Je Naam>python --version
Om te controleren of je Python hebt geïnstalleerd op Linux of Mac, open dan de opdrachtprompt op Linux of het terminalvenster op Mac en voer in:
python --version
Als je Python niet hebt geïnstalleerd op je computer, kun je het gratis downloaden van de volgende website:
Snelle入门
Python is een interpreterende programmeertaal, wat betekent dat je als ontwikkelaar Python-bestanden (.py) kunt schrijven in een teksteditor en deze vervolgens kunt uitvoeren in de Python-interpreter.
Hier is hoe je een Python-bestand uitvoert in de opdrachtprompt:
C:\Gebruikers\Uw Naam>python helloworld.py
waarbij "helloworld.py" de naam van de Python-bestand is.
Laten we onze eerste Python-bestand schrijven, genaamd helloworld.py, dat kan worden voltooid in elk teksteditor.
helloworld.py
print("Hallo, Wereld!")
Zo eenvoudig. Sla het bestand op. Open de opdrachtprompt, navigeer naar de map waar het bestand is opgeslagen en voer dan uit:
C:\Gebruikers\Uw Naam>python helloworld.py
Output:
Hallo, Wereld!
Congratulations, you have written and executed your first Python program.
Python Command Line
To test a small amount of code in python, writing code in a file is sometimes not the fastest or simplest. It is possible to run Python as a command line.
Type the following content on the command line in Windows, Mac, or Linux:
C:\Gebruikers\Uw Naam>python
Here, you can write any python, including the hello world example at the beginning of this tutorial:
C:\Gebruikers\Uw Naam>python Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> print("Hallo, Wereld!")
This will output "Hallo, Wereld!" in the command line:
C:\Gebruikers\Uw Naam>python Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> print("Hallo, Wereld!") Hallo, Wereld!
At any time, you can exit the python command-line interface by typing the following command:
exit()
- Previous Page Introductie tot Python
- Next Page Python Syntax