3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

標準モジュール

# サンプルコード
import os
from datetime import datetime
import math
import random

# 現在のフォルダを示す関数
current_directory = os.getcwd()
print(current_directory)
=> /Users/xxx/python/python-test

# 現在時刻
print(datetime.now())
=> 2025-11-15 17:08:32.903992

# 計算に関する関数
# 円周率
print(math.pi)
=> 3.141592653589793

print(random.randint(0,9))
=> 8

パッケージ

複数のモジュールをまとめたフォルダのこと。
フォルダ内に空のファイル__init__.pyを作成することで、パッケージ化できる。


# test/mypackage/module.py
def hello(name):
    print(f"こんにちは、{name}!")

# test/package_import.py
from mypackage import module1

module1.hello("デンジくん")
=> こんにちはデンジくん!

pipについて

Pythonのパッケージ管理ツール。

専用コマンド

# パッケージ名を指定すると、最新バージョンがインストールされる
pip installl xxx

# バージョン指定
pip instal xxx==2.25.1

# リスト表示
pip list

# 特定パッケージの情報表示
pip show xxx

# 現環境のファイル書き出し
pip freeze > requirements.txt

# 一括インストール
pip instal -r requirements.txt
3
1
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
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?