0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

pythonパッケージ

Posted at
  1. import <モジュール名>
    モジュールがmodule型のオブジェクトとしてインポートされる。
    print()で出力するとどのファイルを読み込んでいるかが確認できる。

  2. モジュールの関数や変数を直接使えるようにインポートしたい場合はfromを使う。import <モジュール名>.<関数名>などとするとエラーとなるので注意。

  3. モジュールをインポートする順番:
    ①標準ライブラリ
    ②サードパーティライブラリ
    ③ローカルライブラリ(自作のライブラリ)

  4. from <モジュール名> import <オブジェクト名:変数名,クラス名,関数名>

  5. from <モジュール名> import *(全てのオブジェクト)

  6. モジュールに別名をつけてインポートする場合:
    import <モジュール名> as <別名>

  7. オブジェクトに別名をつけてインポートする場合:
    from <モジュール名> import <オブジェクト名> as <別名>

7.1 NumPyやpandasなど、省略名でインポートするのが慣例となっているライブラリもある。
import numpy as np
import pandas as pd

  1. パッケージのモジュールをインポートする場合:
    import <パッケージ名>.<モジュール名>
    from<パッケージ名> import<モジュール名>

8.1 オブジェクトをインポートする場合:
from <パッケージ名>.<モジュール名> import <オブジェクト名>
___________________________________

  1. メソッドを呼び出すと、何らかの値を返す
  2. from モジュール名 import クラス名(もしくは関数名や変数名)
0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?