Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use Modules in Python

Shulou Source: shulou.com Published: 2022-06-03 17:41:30 11月13日 Update

This article mainly introduces how to use Modules in Python, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

Description

1. The Modules module is a file that contains Python definitions and statements. The file name with the suffix .py is the module name.

2. In the module, the name of the module can be represented by the global variable _ _ name__ (string).

Example

# Fibonacci numbers module def fib (n): # write Fibonacci series up to na, b = 0,1 while a < n: print (a, end='') a, b = b, axib print () def fib2 (n): # return Fibonacci series up to n result = [] a, b = 0,1 while a < n: result.append (a) a, b = b Arubb return result Thank you for reading this article carefully. I hope the article "how to use Modules in Python" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Tags: Module article name file value global interest variable at the same time suffix character string instance more friend knowledge ribbon industry sentence information Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Redmi Linux vpn Huawei