Python learning notes-custom function import, python learning notes Function

Source: Internet
Author: User

Python learning notes-custom function import, python learning notes Function

Python can put its own classes in The py file, which is then called by other programs. Today we will share with you how to reference custom classes and functions from the file in shell, the specific process is as follows:

Step 1 declare the encoding type of the file you wrote


Save the file you wrote as a file in the py format. The path you saved will be used later.


Introduce the sys module and add the path to the path, that is, the path mentioned in the previous step.


Note:The reference method isFrom file name import Class Name


The call method is as follows: we create a column content


The same method is used to call custom functions.

 

 

  • The size is 55.1 KB.
  • The size is 77.6 KB.
  • The size is 23.8 KB.
  • The size is 41.4 KB.
  • The size is 11.7 KB.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.