コンテンツにスキップ

未翻訳のページ

このページはまだ日本語に翻訳されていないため、英語の原文を表示しています。 翻訳に協力する

netrc Module

The netrc module parses and encapsulates the .netrc file, which contains login credentials for various hosts.

Complexity Reference

Operation Time Space Notes
netrc() parse O(n) O(n) n = file size
Lookup auth O(1) O(1) Hash-based

Working with Netrc Files

Reading .netrc File

import netrc

# Parse netrc - O(n)
rc = netrc.netrc()

# Get authentication - O(1)
auth = rc.authenticators('github.com')
if auth:
    login, _, password = auth
    print(f"Login: {login}")

.netrc Format

machine github.com
login username
password secret_token

machine pypi.org
login __token__
password pypi-token-here