Get the App
SLTechnology News&Howtos  ›  Development  › 

Definition and usage of annotations in Python

Shulou Source: shulou.com Published: 2022-06-03 18:49:02 09月17日 Update

This article focuses on the definition and usage of annotations in Python. Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn the definition and usage of annotations in Python.

1. Annotation

Define

Requirements: when writing a program, the writer gives an explanation or hint of a statement, program segment, function, etc., which can improve the readability of the program code.

Definition: interpretation and description of the code

Purpose: to make it easier for people to understand the code

Single-line comment

# this is a single-line comment print ("hello world") # comments can also be written at the end of the code

Pycharm shortcut: ctrl + /

Multiline comment

The function completed by the "" code is to print out hello world 1. First call the print function 2. Pass in the parameter "print ('hello worldview') to the print function."

Job log description

# TODO description # is equivalent to adding a label to the program, telling programmers what else needs to be dealt with here. I believe you have a deeper understanding of "the definition and usage of comments in Python". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Comments programs code functions content learning interpretation output utility deeper people interests functions parameters readability practicality practicality shortcuts simple operation text Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Shulou Tech Info Huawei Redmi MariaDB