Wprowadzenie do Pythona
- Poprzednia strona Wprowadzenie do Pythona
- Następna strona Gramatyka Pythona
Python Installation
Many PCs and Macs have Python pre-installed.
To check if Python is installed on a Windows PC, look for Python in the start bar or run the following command on the command line (cmd.exe):
C:\Users\Your Name>python --version
To check if you have Python installed on Linux or Mac, open the command line on Linux or the terminal on Mac and type:
python --version
If you find that Python is not installed on your computer, you can download it for free from the following website:
Quick Start to Python
Python is an interpreted programming language, which means as a developer, you can write Python (.py) files in a text editor and then execute these files in the Python interpreter.
The way to run a Python file on the command line is as follows:
C:\Users\Twoje Imię>python helloworld.py
In this case, "helloworld.py" is the filename for Python.
Let's write our first Python file, named helloworld.py, which can be completed in any text editor.
helloworld.py
print("Hello, World!")
To simplify, save the file. Open the command line, navigate to the directory where the file is saved, and then run:
C:\Users\Twoje Imię>python helloworld.py
Wynik:
Cześć, Świat!
Gratulacje, napisałeś i wykonałeś pierwszy program Python.
Wiersz poleceń Python
Testowanie małych fragmentów kodu w Pythonie w pliku nie zawsze jest najszybszym i najprostszym rozwiązaniem. Możesz uruchamiać Python jako wiersz poleceń.
Wpisz następujące polecenie w wierszu poleceń na Windows, Mac lub Linux:
C:\Users\Twoje Imię>python
Tutaj możesz napisać dowolny kod Python, w tym przykłady z tej lekcji, takie jak hello world:
C:\Users\Twoje Imię>python Python 3.6.4 (v3.6.4:d48eceb, 19 grudnia 2017, 06:04:45) [MSC v.1900 32 bit (Intel)] na win32 Wpisz "pomoc", "copyright", "credits" lub "license", aby uzyskać więcej informacji. >>> print("Cześć, Świat!")
To wyświetli "Cześć, Świat!" w wierszu poleceń:
C:\Users\Twoje Imię>python Python 3.6.4 (v3.6.4:d48eceb, 19 grudnia 2017, 06:04:45) [MSC v.1900 32 bit (Intel)] na win32 Wpisz "pomoc", "copyright", "credits" lub "license", aby uzyskać więcej informacji. >>> print("Cześć, Świat!") Cześć, Świat!
W każdej chwili możesz wyjść z interfejsu wiersza poleceń Pythona, wpisując następujące polecenie:
exit()
- Poprzednia strona Wprowadzenie do Pythona
- Następna strona Gramatyka Pythona