Hướng dẫn how do you add libraries to your program in python? - làm cách nào để bạn thêm thư viện vào chương trình của mình trong python?

  • Quy tắc ứng xử
  • Thành lập
  • Tập phim
  • Bổ sung
  • Giấy phép
  • Cải thiện trang này

Show

Tổng quan

Giảng dạy: 10 phút Bài tập: 10 phút 10 min
Exercises: 10 min

Câu hỏi

  • Làm thế nào tôi có thể mở rộng khả năng của Python?

  • Làm thế nào tôi có thể sử dụng phần mềm mà người khác đã viết?

  • Làm thế nào tôi có thể tìm ra phần mềm đó làm gì?

Mục tiêu

  • Giải thích các thư viện phần mềm là gì và tại sao các lập trình viên tạo và sử dụng chúng.

  • Viết các chương trình nhập và sử dụng thư viện từ thư viện tiêu chuẩn Python.

  • Tìm và đọc tài liệu cho các thư viện tiêu chuẩn tương tác (trong thông dịch viên) và trực tuyến.

Hầu hết sức mạnh của một ngôn ngữ lập trình nằm trong các thư viện (phần mềm) của nó.

  • Thư viện (phần mềm) là một tập hợp các tệp (được gọi là mô -đun) chứa các chức năng để sử dụng bởi các chương trình khác.
    • Cũng có thể chứa các giá trị dữ liệu (ví dụ: hằng số số) và những thứ khác.
    • Nội dung thư viện được cho là có liên quan, nhưng không có cách nào để thực thi điều đó.
  • Thư viện tiêu chuẩn Python là một bộ mô -đun rộng lớn đi kèm với chính Python.
  • Nhiều thư viện bổ sung có sẵn từ PYPI (Chỉ số gói Python).
  • Chúng ta sẽ xem sau làm thế nào để viết thư viện mới.

Thư viện và mô -đun

Thư viện là một tập hợp các mô -đun, nhưng các thuật ngữ thường được sử dụng thay thế cho nhau, đặc biệt là vì nhiều thư viện chỉ bao gồm một mô -đun duy nhất, vì vậy đừng lo lắng nếu bạn trộn chúng.

Một chương trình phải nhập mô -đun thư viện trước khi sử dụng nó.

  • Sử dụng
    The lower ascii letters are abcdefghijklmnopqrstuvwxyz
    Capitalise This Sentence Please.
    
    9 để tải mô -đun thư viện vào bộ nhớ chương trình.
  • Sau đó tham khảo mọi thứ từ mô -đun là
    Help on module string:
    
    NAME
        string - A collection of string constants.
    
    MODULE REFERENCE
        https://docs.python.org/3.6/library/string
        
        The following documentation is automatically generated from the Python
        source files.  It may be incomplete, incorrect or include features that
        are considered implementation detail and may vary between Python
        implementations.  When in doubt, consult the module reference at the
        location listed above.
    
    DESCRIPTION
        Public module variables:
        
        whitespace -- a string containing all ASCII whitespace
        ascii_lowercase -- a string containing all ASCII lowercase letters
        ascii_uppercase -- a string containing all ASCII uppercase letters
        ascii_letters -- a string containing all ASCII letters
        digits -- a string containing all ASCII decimal digits
        hexdigits -- a string containing all ASCII hexadecimal digits
        octdigits -- a string containing all ASCII octal digits
        punctuation -- a string containing all ASCII punctuation characters
        printable -- a string containing all ASCII characters considered printable
    
    CLASSES
        builtins.object
            Formatter
            Template
    ⋮ ⋮ ⋮
    
    0.
    • Python sử dụng
      Help on module string:
      
      NAME
          string - A collection of string constants.
      
      MODULE REFERENCE
          https://docs.python.org/3.6/library/string
          
          The following documentation is automatically generated from the Python
          source files.  It may be incomplete, incorrect or include features that
          are considered implementation detail and may vary between Python
          implementations.  When in doubt, consult the module reference at the
          location listed above.
      
      DESCRIPTION
          Public module variables:
          
          whitespace -- a string containing all ASCII whitespace
          ascii_lowercase -- a string containing all ASCII lowercase letters
          ascii_uppercase -- a string containing all ASCII uppercase letters
          ascii_letters -- a string containing all ASCII letters
          digits -- a string containing all ASCII decimal digits
          hexdigits -- a string containing all ASCII hexadecimal digits
          octdigits -- a string containing all ASCII octal digits
          punctuation -- a string containing all ASCII punctuation characters
          printable -- a string containing all ASCII characters considered printable
      
      CLASSES
          builtins.object
              Formatter
              Template
      ⋮ ⋮ ⋮
      
      1 để có nghĩa là một phần của người Hồi giáo.
  • Sử dụng
    Help on module string:
    
    NAME
        string - A collection of string constants.
    
    MODULE REFERENCE
        https://docs.python.org/3.6/library/string
        
        The following documentation is automatically generated from the Python
        source files.  It may be incomplete, incorrect or include features that
        are considered implementation detail and may vary between Python
        implementations.  When in doubt, consult the module reference at the
        location listed above.
    
    DESCRIPTION
        Public module variables:
        
        whitespace -- a string containing all ASCII whitespace
        ascii_lowercase -- a string containing all ASCII lowercase letters
        ascii_uppercase -- a string containing all ASCII uppercase letters
        ascii_letters -- a string containing all ASCII letters
        digits -- a string containing all ASCII decimal digits
        hexdigits -- a string containing all ASCII hexadecimal digits
        octdigits -- a string containing all ASCII octal digits
        punctuation -- a string containing all ASCII punctuation characters
        printable -- a string containing all ASCII characters considered printable
    
    CLASSES
        builtins.object
            Formatter
            Template
    ⋮ ⋮ ⋮
    
    2, một trong các mô -đun trong thư viện tiêu chuẩn:

import string

print('The lower ascii letters are', string.ascii_lowercase)
print(string.capwords('capitalise this sentence please.'))

The lower ascii letters are abcdefghijklmnopqrstuvwxyz
Capitalise This Sentence Please.

  • Bạn phải tham khảo từng mục với tên mô -đun.
    • Help on module string:
      
      NAME
          string - A collection of string constants.
      
      MODULE REFERENCE
          https://docs.python.org/3.6/library/string
          
          The following documentation is automatically generated from the Python
          source files.  It may be incomplete, incorrect or include features that
          are considered implementation detail and may vary between Python
          implementations.  When in doubt, consult the module reference at the
          location listed above.
      
      DESCRIPTION
          Public module variables:
          
          whitespace -- a string containing all ASCII whitespace
          ascii_lowercase -- a string containing all ASCII lowercase letters
          ascii_uppercase -- a string containing all ASCII uppercase letters
          ascii_letters -- a string containing all ASCII letters
          digits -- a string containing all ASCII decimal digits
          hexdigits -- a string containing all ASCII hexadecimal digits
          octdigits -- a string containing all ASCII octal digits
          punctuation -- a string containing all ASCII punctuation characters
          printable -- a string containing all ASCII characters considered printable
      
      CLASSES
          builtins.object
              Formatter
              Template
      ⋮ ⋮ ⋮
      
      3 won công việc của người Viking: Tài liệu tham khảo về
      Help on module string:
      
      NAME
          string - A collection of string constants.
      
      MODULE REFERENCE
          https://docs.python.org/3.6/library/string
          
          The following documentation is automatically generated from the Python
          source files.  It may be incomplete, incorrect or include features that
          are considered implementation detail and may vary between Python
          implementations.  When in doubt, consult the module reference at the
          location listed above.
      
      DESCRIPTION
          Public module variables:
          
          whitespace -- a string containing all ASCII whitespace
          ascii_lowercase -- a string containing all ASCII lowercase letters
          ascii_uppercase -- a string containing all ASCII uppercase letters
          ascii_letters -- a string containing all ASCII letters
          digits -- a string containing all ASCII decimal digits
          hexdigits -- a string containing all ASCII hexadecimal digits
          octdigits -- a string containing all ASCII octal digits
          punctuation -- a string containing all ASCII punctuation characters
          printable -- a string containing all ASCII characters considered printable
      
      CLASSES
          builtins.object
              Formatter
              Template
      ⋮ ⋮ ⋮
      
      4 bằng cách nào đó bằng cách nào đó, kế thừa, chức năng tham chiếu đến
      Help on module string:
      
      NAME
          string - A collection of string constants.
      
      MODULE REFERENCE
          https://docs.python.org/3.6/library/string
          
          The following documentation is automatically generated from the Python
          source files.  It may be incomplete, incorrect or include features that
          are considered implementation detail and may vary between Python
          implementations.  When in doubt, consult the module reference at the
          location listed above.
      
      DESCRIPTION
          Public module variables:
          
          whitespace -- a string containing all ASCII whitespace
          ascii_lowercase -- a string containing all ASCII lowercase letters
          ascii_uppercase -- a string containing all ASCII uppercase letters
          ascii_letters -- a string containing all ASCII letters
          digits -- a string containing all ASCII decimal digits
          hexdigits -- a string containing all ASCII hexadecimal digits
          octdigits -- a string containing all ASCII octal digits
          punctuation -- a string containing all ASCII punctuation characters
          printable -- a string containing all ASCII characters considered printable
      
      CLASSES
          builtins.object
              Formatter
              Template
      ⋮ ⋮ ⋮
      
      2.

Sử dụng Help on module string: NAME string - A collection of string constants. MODULE REFERENCE https://docs.python.org/3.6/library/string The following documentation is automatically generated from the Python source files. It may be incomplete, incorrect or include features that are considered implementation detail and may vary between Python implementations. When in doubt, consult the module reference at the location listed above. DESCRIPTION Public module variables: whitespace -- a string containing all ASCII whitespace ascii_lowercase -- a string containing all ASCII lowercase letters ascii_uppercase -- a string containing all ASCII uppercase letters ascii_letters -- a string containing all ASCII letters digits -- a string containing all ASCII decimal digits hexdigits -- a string containing all ASCII hexadecimal digits octdigits -- a string containing all ASCII octal digits punctuation -- a string containing all ASCII punctuation characters printable -- a string containing all ASCII characters considered printable CLASSES builtins.object Formatter Template ⋮ ⋮ ⋮ 6 để tìm hiểu về nội dung của mô -đun thư viện.

  • Hoạt động giống như trợ giúp cho một chức năng.

Help on module string:

NAME
    string - A collection of string constants.

MODULE REFERENCE
    https://docs.python.org/3.6/library/string
    
    The following documentation is automatically generated from the Python
    source files.  It may be incomplete, incorrect or include features that
    are considered implementation detail and may vary between Python
    implementations.  When in doubt, consult the module reference at the
    location listed above.

DESCRIPTION
    Public module variables:
    
    whitespace -- a string containing all ASCII whitespace
    ascii_lowercase -- a string containing all ASCII lowercase letters
    ascii_uppercase -- a string containing all ASCII uppercase letters
    ascii_letters -- a string containing all ASCII letters
    digits -- a string containing all ASCII decimal digits
    hexdigits -- a string containing all ASCII hexadecimal digits
    octdigits -- a string containing all ASCII octal digits
    punctuation -- a string containing all ASCII punctuation characters
    printable -- a string containing all ASCII characters considered printable

CLASSES
    builtins.object
        Formatter
        Template
⋮ ⋮ ⋮

Nhập các mục cụ thể từ mô -đun thư viện để rút ngắn các chương trình.

  • Sử dụng
    Help on module string:
    
    NAME
        string - A collection of string constants.
    
    MODULE REFERENCE
        https://docs.python.org/3.6/library/string
        
        The following documentation is automatically generated from the Python
        source files.  It may be incomplete, incorrect or include features that
        are considered implementation detail and may vary between Python
        implementations.  When in doubt, consult the module reference at the
        location listed above.
    
    DESCRIPTION
        Public module variables:
        
        whitespace -- a string containing all ASCII whitespace
        ascii_lowercase -- a string containing all ASCII lowercase letters
        ascii_uppercase -- a string containing all ASCII uppercase letters
        ascii_letters -- a string containing all ASCII letters
        digits -- a string containing all ASCII decimal digits
        hexdigits -- a string containing all ASCII hexadecimal digits
        octdigits -- a string containing all ASCII octal digits
        punctuation -- a string containing all ASCII punctuation characters
        printable -- a string containing all ASCII characters considered printable
    
    CLASSES
        builtins.object
            Formatter
            Template
    ⋮ ⋮ ⋮
    
    7 để chỉ tải các mục cụ thể từ mô -đun thư viện.
  • Sau đó tham khảo chúng trực tiếp mà không có tên thư viện là tiền tố.

from string import ascii_letters

print('The ASCII letters are', ascii_letters)

The ASCII letters are abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ

Tạo bí danh cho một mô -đun thư viện khi nhập nó để rút ngắn các chương trình.

  • Sử dụng
    Help on module string:
    
    NAME
        string - A collection of string constants.
    
    MODULE REFERENCE
        https://docs.python.org/3.6/library/string
        
        The following documentation is automatically generated from the Python
        source files.  It may be incomplete, incorrect or include features that
        are considered implementation detail and may vary between Python
        implementations.  When in doubt, consult the module reference at the
        location listed above.
    
    DESCRIPTION
        Public module variables:
        
        whitespace -- a string containing all ASCII whitespace
        ascii_lowercase -- a string containing all ASCII lowercase letters
        ascii_uppercase -- a string containing all ASCII uppercase letters
        ascii_letters -- a string containing all ASCII letters
        digits -- a string containing all ASCII decimal digits
        hexdigits -- a string containing all ASCII hexadecimal digits
        octdigits -- a string containing all ASCII octal digits
        punctuation -- a string containing all ASCII punctuation characters
        printable -- a string containing all ASCII characters considered printable
    
    CLASSES
        builtins.object
            Formatter
            Template
    ⋮ ⋮ ⋮
    
    8 để cung cấp cho thư viện một bí danh ngắn trong khi nhập nó.
  • Sau đó tham khảo các mục trong thư viện bằng cách sử dụng tên rút ngắn đó.

import string as s

print(s.capwords('capitalise this sentence again please.'))

Capitalise This Sentence Again Please.

  • Thường được sử dụng cho các thư viện thường được sử dụng hoặc có tên dài.
    • Ví dụ: thư viện
      Help on module string:
      
      NAME
          string - A collection of string constants.
      
      MODULE REFERENCE
          https://docs.python.org/3.6/library/string
          
          The following documentation is automatically generated from the Python
          source files.  It may be incomplete, incorrect or include features that
          are considered implementation detail and may vary between Python
          implementations.  When in doubt, consult the module reference at the
          location listed above.
      
      DESCRIPTION
          Public module variables:
          
          whitespace -- a string containing all ASCII whitespace
          ascii_lowercase -- a string containing all ASCII lowercase letters
          ascii_uppercase -- a string containing all ASCII uppercase letters
          ascii_letters -- a string containing all ASCII letters
          digits -- a string containing all ASCII decimal digits
          hexdigits -- a string containing all ASCII hexadecimal digits
          octdigits -- a string containing all ASCII octal digits
          punctuation -- a string containing all ASCII punctuation characters
          printable -- a string containing all ASCII characters considered printable
      
      CLASSES
          builtins.object
              Formatter
              Template
      ⋮ ⋮ ⋮
      
      9 thường được đặt bí danh là
      from string import ascii_letters
      
      print('The ASCII letters are', ascii_letters)
      
      0.
  • Nhưng có thể làm cho các chương trình khó hiểu hơn, vì độc giả phải học các bí danh chương trình của bạn.

Khám phá thư viện hệ điều hành

Thư viện HĐH cung cấp một cách truy cập chức năng hệ điều hành.

  1. Bạn có thể sử dụng chức năng nào từ thư viện
    from string import ascii_letters
    
    print('The ASCII letters are', ascii_letters)
    
    1 để xác định thư mục làm việc hiện tại?

Dung dịch

  1. Sử dụng
    from string import ascii_letters
    
    print('The ASCII letters are', ascii_letters)
    
    2, chúng tôi thấy rằng chúng tôi đã có
    from string import ascii_letters
    
    print('The ASCII letters are', ascii_letters)
    
    3 trả về một chuỗi đại diện cho thư mục làm việc hiện tại.

Định vị đúng mô -đun

Với các biến

from string import ascii_letters

print('The ASCII letters are', ascii_letters)
4,
from string import ascii_letters

print('The ASCII letters are', ascii_letters)
5 và
from string import ascii_letters

print('The ASCII letters are', ascii_letters)
6, làm thế nào bạn sẽ tạo ra một ngày ở định dạng ISO tiêu chuẩn:

year = 2016
month = 10
day = 22

  1. Mô -đun thư viện tiêu chuẩn nào có thể giúp bạn?
  2. Bạn sẽ chọn chức năng nào từ mô -đun đó?
  3. Cố gắng viết một chương trình sử dụng chức năng.

Dung dịch

Sử dụng

from string import ascii_letters

print('The ASCII letters are', ascii_letters)
2, chúng tôi thấy rằng chúng tôi đã có
from string import ascii_letters

print('The ASCII letters are', ascii_letters)
3 trả về một chuỗi đại diện cho thư mục làm việc hiện tại.

Định vị đúng mô -đun

import datetime

iso_date = datetime.date(year, month, day).isoformat()
print(iso_date)

Với các biến

from string import ascii_letters

print('The ASCII letters are', ascii_letters)
4,
from string import ascii_letters

print('The ASCII letters are', ascii_letters)
5 và
from string import ascii_letters

print('The ASCII letters are', ascii_letters)
6, làm thế nào bạn sẽ tạo ra một ngày ở định dạng ISO tiêu chuẩn:

import datetime

print(datetime.date(year, month, day).isoformat())

Mô -đun thư viện tiêu chuẩn nào có thể giúp bạn?

Bạn sẽ chọn chức năng nào từ mô -đun đó?

The lower ascii letters are abcdefghijklmnopqrstuvwxyz
Capitalise This Sentence Please.
0

Cố gắng viết một chương trình sử dụng chức năng.

Dung dịch

Sử dụng

from string import ascii_letters

print('The ASCII letters are', ascii_letters)
2, chúng tôi thấy rằng chúng tôi đã có
from string import ascii_letters

print('The ASCII letters are', ascii_letters)
3 trả về một chuỗi đại diện cho thư mục làm việc hiện tại.

Định vị đúng mô -đun

  1. Với các biến
    from string import ascii_letters
    
    print('The ASCII letters are', ascii_letters)
    
    4,
    from string import ascii_letters
    
    print('The ASCII letters are', ascii_letters)
    
    5 và
    from string import ascii_letters
    
    print('The ASCII letters are', ascii_letters)
    
    6, làm thế nào bạn sẽ tạo ra một ngày ở định dạng ISO tiêu chuẩn:
  2. Mô -đun thư viện tiêu chuẩn nào có thể giúp bạn?
  3. Bạn sẽ chọn chức năng nào từ mô -đun đó?

The lower ascii letters are abcdefghijklmnopqrstuvwxyz
Capitalise This Sentence Please.
1

Dung dịch

The lower ascii letters are abcdefghijklmnopqrstuvwxyz
Capitalise This Sentence Please.
2

Sử dụng

from string import ascii_letters

print('The ASCII letters are', ascii_letters)
2, chúng tôi thấy rằng chúng tôi đã có
from string import ascii_letters

print('The ASCII letters are', ascii_letters)
3 trả về một chuỗi đại diện cho thư mục làm việc hiện tại.

The lower ascii letters are abcdefghijklmnopqrstuvwxyz
Capitalise This Sentence Please.
3

Định vị đúng mô -đun

Với các biến from string import ascii_letters print('The ASCII letters are', ascii_letters) 4, from string import ascii_letters print('The ASCII letters are', ascii_letters) 5 và from string import ascii_letters print('The ASCII letters are', ascii_letters) 6, làm thế nào bạn sẽ tạo ra một ngày ở định dạng ISO tiêu chuẩn:

Mô -đun thư viện tiêu chuẩn nào có thể giúp bạn?

Bạn sẽ chọn chức năng nào từ mô -đun đó?

The lower ascii letters are abcdefghijklmnopqrstuvwxyz
Capitalise This Sentence Please.
4

Cố gắng viết một chương trình sử dụng chức năng.

The lower ascii letters are abcdefghijklmnopqrstuvwxyz
Capitalise This Sentence Please.
5

Dung dịch

Sử dụng

from string import ascii_letters

print('The ASCII letters are', ascii_letters)
2, chúng tôi thấy rằng chúng tôi đã có
from string import ascii_letters

print('The ASCII letters are', ascii_letters)
3 trả về một chuỗi đại diện cho thư mục làm việc hiện tại.

Định vị đúng mô -đun

  1. Với các biến
    from string import ascii_letters
    
    print('The ASCII letters are', ascii_letters)
    
    4,
    from string import ascii_letters
    
    print('The ASCII letters are', ascii_letters)
    
    5 và
    from string import ascii_letters
    
    print('The ASCII letters are', ascii_letters)
    
    6, làm thế nào bạn sẽ tạo ra một ngày ở định dạng ISO tiêu chuẩn:
  2. Bạn có thấy phiên bản này dễ đọc hơn so với phiên bản trước không?
  3. Tại sao các lập trình viên sẽ luôn sử dụng hình thức này của
    The lower ascii letters are abcdefghijklmnopqrstuvwxyz
    Capitalise This Sentence Please.
    
    9?

The lower ascii letters are abcdefghijklmnopqrstuvwxyz
Capitalise This Sentence Please.
6

Dung dịch

The lower ascii letters are abcdefghijklmnopqrstuvwxyz
Capitalise This Sentence Please.
7

Nhiều khả năng bạn thấy phiên bản này dễ đọc hơn vì nó ít dày đặc hơn. Lý do chính để không sử dụng hình thức nhập khẩu này là để tránh các cuộc đụng độ tên. Chẳng hạn, bạn sẽ nhập

import string as s

print(s.capwords('capitalise this sentence again please.'))
4 theo cách này nếu bạn cũng muốn sử dụng tên
import string as s

print(s.capwords('capitalise this sentence again please.'))
4 cho một biến hoặc chức năng của riêng bạn. Hoặc nếu bạn cũng nhập một hàm có tên
import string as s

print(s.capwords('capitalise this sentence again please.'))
4 từ một thư viện khác.

Đọc thông báo lỗi

  1. Đọc mã bên dưới và cố gắng xác định các lỗi là gì mà không cần chạy nó.
  2. Chạy mã và đọc thông báo lỗi. Đó là loại lỗi nào?

The lower ascii letters are abcdefghijklmnopqrstuvwxyz
Capitalise This Sentence Please.
8

Dung dịch

  1. Nhiều khả năng bạn thấy phiên bản này dễ đọc hơn vì nó ít dày đặc hơn. Lý do chính để không sử dụng hình thức nhập khẩu này là để tránh các cuộc đụng độ tên. Chẳng hạn, bạn sẽ nhập
    import string as s
    
    print(s.capwords('capitalise this sentence again please.'))
    
    4 theo cách này nếu bạn cũng muốn sử dụng tên
    import string as s
    
    print(s.capwords('capitalise this sentence again please.'))
    
    4 cho một biến hoặc chức năng của riêng bạn. Hoặc nếu bạn cũng nhập một hàm có tên
    import string as s
    
    print(s.capwords('capitalise this sentence again please.'))
    
    4 từ một thư viện khác.
  2. Đọc thông báo lỗi

Đọc mã bên dưới và cố gắng xác định các lỗi là gì mà không cần chạy nó.

  • Chạy mã và đọc thông báo lỗi. Đó là loại lỗi nào?

  • Đối tượng ngày có các đối số trong năm, tháng, ngày, nên 13 là một giá trị không hợp lệ trong tháng.

  • Bạn nhận được một lỗi của loại giá trị, giá trị, chỉ ra rằng đối tượng nhận được giá trị đối số không phù hợp. Thông điệp bổ sung Tháng Tháng phải có trong 1..12, làm cho nó rõ ràng hơn về vấn đề là gì.

  • Những điểm chính

  • Hầu hết sức mạnh của một ngôn ngữ lập trình là trong các thư viện của nó.

Làm thế nào để bạn thêm thư viện trong Python?

Một chương trình phải nhập mô -đun thư viện trước khi sử dụng ...
Sử dụng nhập để tải mô -đun thư viện vào bộ nhớ của chương trình ..
Sau đó, hãy tham khảo mọi thứ từ mô -đun là module_name. điều_name. Python sử dụng. có nghĩa là một phần của người Viking ..
Sử dụng toán học, một trong các mô -đun trong thư viện tiêu chuẩn:.

Lệnh cài đặt thư viện trong Python là gì?

Để cài đặt gói bao gồm tệp setup.py, mở một cửa sổ lệnh hoặc thiết bị đầu cuối và: CD vào thư mục gốc nơi đặt setup.py. Nhập: Cài đặt python setup.py.python setup.py install.

Tôi nên đặt thư viện Python ở đâu?

Thông thường, thư viện Python được đặt trong thư mục trang web trang web trong thư mục cài đặt Python, tuy nhiên, nếu nó không nằm trong thư mục trang web trang web và bạn không chắc chắn nơi được cài đặt, đây là mẫu Python để định vị các mô-đun Python được cài đặttrên máy tính của bạn.site-packages folder within the Python install directory, however, if it is not located in the site-packages folder and you are uncertain where it is installed, here is a Python sample to locate Python modules installed on your computer.

Làm cách nào để nhập thư viện vào PIP?

Đảm bảo bạn có thể chạy PIP từ dòng lệnh..
Tải xuống an toàn get-pip.py 1 ..
Chạy Python get-pip.py.2 Điều này sẽ cài đặt hoặc nâng cấp PIP.Ngoài ra, nó sẽ cài đặt setuptools và bánh xe nếu chúng chưa được cài đặt.Cảnh báo..