Size: 2132
Comment:
|
Size: 4732
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 4: | Line 4: |
On most platforms, the interpreter is called by '''`python(1)`'''. Some platforms distribute with version suffixes that may or may not be optional. The `py(1)` launcher is also available. |
|
Line 13: | Line 15: |
A hello world program looks like: | {{{ #!/usr/bin/env python print("Hello, world") }}} A program is more commonly structured like: |
Line 16: | Line 23: |
#!/usr/bin/env python |
|
Line 26: | Line 35: |
#!/usr/bin/env python2 | |
Line 33: | Line 43: |
# or chmod 755 hello.py ./hello.py |
|
Line 46: | Line 53: |
* [[Python/Pipx|pipx]] | |
Line 47: | Line 55: |
* [[Python/PyCompile|py_compile]] * [[Python/Six|six]] * [[Python/TimeIt|timeit]] * [[Python/TypeAnnotation|Type Annotation]] * [[Python/Unittest|unittest]] |
|
Line 48: | Line 61: |
* [[Python/Unittest|unittest]] * [[Python/TypeAnnotation|Type Annotation]] |
|
Line 55: | Line 66: |
* [[Encryption/Certbot|certbot]] | |
Line 60: | Line 72: |
* [[Python/UWSGI|uWSGI]] | * [[Python/Uwsgi|uWSGI]] |
Line 71: | Line 83: |
* [[Python/Generator|Generators]] | |
Line 72: | Line 85: |
* [[Python/StringMethods|String methods]] | |
Line 77: | Line 91: |
* [[Python/Base64|base64]] * [[Python/CMath|cmath]] |
|
Line 79: | Line 96: |
* [[Python/CollectionsAbc|collections.abc]] | * [[Python/Collections/Abc|collections.abc]] * [[Python/ConfigParser|configparser]] |
Line 81: | Line 99: |
* [[Python/Copy|copy]] * [[Python/Csv|csv]] * [[Python/DataClasses|dataclasses]] * [[Python/Datetime|datetime]] * [[Python/Datetime/Date|datetime.date]] * [[Python/Datetime/Datetime|datetime.datetime]] * [[Python/Datetime/Time|datetime.time]] * [[Python/Datetime/TimeDelta|datetime.timedelta]] * [[Python/Decimal|decimal]] * [[Python/DiffLib|difflib]] * [[Python/Email|email]] * [[Python/Email/ContentManager|email.contentmanager]] * [[Python/Email/Errors|email.errors]] * [[Python/Email/Message|email.message]] * [[Python/Email/Parser|email.parser]] * [[Python/Enum|enum]] * [[Python/FileCmp|filecmp]] * [[Python/Fractions|fractions]] * [[Python/FtpLib|ftplib]] * [[Python/FuncTools|functools]] * [[Python/GetPass|getpass]] * [[Python/Html|html]] * [[Python/Html/Parser|html.parser]] * [[Python/ImapLib|imaplib]] * [[Python/Inspect|inspect]] * [[Python/IO|io]] * [[Python/IterTools|itertools]] * [[Python/Json|json]] * [[Python/Math|math]] * [[Python/Operator|operator]] * [[Python/Os|os]] * [[Python/Os/Path|os.path]] * [[Python/PathLib|pathlib]] * [[Python/Pickle|pickle]] * [[Python/PopLib|poplib]] * [[Python/PPrint|pprint]] * [[Python/QuoPri|quopri]] * [[Python/Random|random]] |
|
Line 82: | Line 138: |
* [[Python/ShUtil|shutil]] * [[Python/SmtpLib|smtplib]] * [[Python/Sqlite3|sqlite3]] * [[Python/Statistics|statistics]] * [[Python/Strings|strings]] * [[Python/Sys|sys]] * [[Python/TempFile|tempfile]] * [[Python/TkInter|tkinter]] * [[Python/TomlLib|tomllib]] |
|
Line 83: | Line 148: |
== Parser Modules and Classes == === Configuration Files === * [[Python/ConfigParser|ConfigParser]] === HTML === * [[Python/HtmlParser|html.parser]] * [[Python/BeautifulSoup|Beautiful Soup]] === PDF === * [[Python/Pdfminer|pdfminer]] === XML === |
* [[Python/UrlLib|urllib]] * [[Python/XmlDomMinidom|xml.dom.minidom]] |
Line 104: | Line 151: |
* [[Python/XmlDomMinidom|xml.dom.minidom]] * [[Python/LxmlEtree|lxml.etree]] |
|
Line 111: | Line 156: |
* [[Python/BeautifulSoup|Beautiful Soup]] | |
Line 112: | Line 158: |
* [[Python/HuggingFace|Hugging Face]] * [[Python/LxmlEtree|lxml.etree]] |
|
Line 114: | Line 162: |
* [[Python/Pandas|Pandas]] * [[Python/Pdfminer|pdfminer]] * [[Python/Pillow|Pillow]] * [[Python/Pygments|Pygments]] * [[Python/Requests|Requests]] |
|
Line 115: | Line 168: |
* [[SPSS/Python|SPSS' proprietary interface (spss, spssaux, spssdata, and SpssClient)]] * [[Stata/Python|Stata's proprietary interface (sfi)]] * [[Python/SqlAlchemy|SqlAlchemy]] |
|
Line 123: | Line 179: |
---- == See also == [[https://docs.python.org/3/reference/index.html|The Python Language Reference]] [[https://docs.python.org/3/library/index.html|The Python Standard Library]], the standard library reference manual [[https://pymotw.com/3/|Python Module of the Week blog]] |
Python
The Python programming language is an interpreted, duck-typed language.
On most platforms, the interpreter is called by python(1). Some platforms distribute with version suffixes that may or may not be optional. The py(1) launcher is also available.
Contents
Example
print("Hello, world")
A program is more commonly structured like:
def main(): print("Hello, world") if __name__ == "__main__": main()
If using Python 2, the print command is instead a statement.
print "Hello, world"
To run the program, try:
python hello.py
Tool chain
Applications and Servers
Language
Standard Library Modules
Third-Party Modules
Creating Libraries
See also
The Python Standard Library, the standard library reference manual
Python Module of the Week blog