のぶ江

Pythonリファレンス

コマンド化して実行関連のリファレンス

コマンド化して実行関連 コマンド実行形式化 pyinstaller HW.py --onefile パラメータ import sys sys.argv ⇒コマンド名自体 sys.argv ⇒第一引数 ...
Pythonリファレンス

JSON操作関連リファレンス

JSON操作関連 JSONデータの扱い jsonパッケージでJSON化したデーターは、辞書やリストとして扱える 文字列をJSON化 import json jsonstr = '{ a: "hoge", b: ...
Pythonリファレンス

re(正規表現)関連リファレンス

re(正規表現) match() ※先頭からの比較となる import re match = re.match('http.*'+hostname+'/(.*)/', ]) pathname = match....
Pythonリファレンス

文字列操作関連リファレンス

文字列関連 文字列の最後が指定された文字列か? if str.endswith('jpg'): ⇒strが'jpg'で終わっている(strがaaa.jpgなら真、aaa.txtなら偽) 書式付き文...
Pythonリファレンス

BeautifulSoup関連リファレンス

BeautifulSoup soupを生成 from bs4 import BeautifulSoup response = requests.get(url) response.encoding = res...
Pythonリファレンス

httpアクセス関連リファレンス

httpアクセス関連 urljoinとurllib.requestでGET import urllib.request from urllib.parse import urljoin url = urljoin("...
Pythonリファレンス

ZIPファイル操作関連リファレンス

ZIPファイル操作 ZIPファイルの解凍 import zipfile zipfile = './zipfile.zip' with zipfile.ZipFile(zipfile) as zip: ...
Pythonリファレンス

ファイル読み書き関連リファレンス

ファイル読み書き 読み込みオープン with open(path) as f: f.read() 書き込みオープン with open('./param.json', 'w') as...
Pythonリファレンス

ファイルのコピーや移動、削除

ファイルのコピーや移動、削除 コピー(更新日など属性ごと) import shutil shutil.copy2(srcpath, destpath) 移動 import shutil s...
Pythonリファレンス

ファイルパスやディレクトリ関連のリファレンス

ファイルパスやディレクトリ関連 パスの結合 import io path = os.path.join(wp_path, 'wp-content/plugins') リネーム os.rename...
タイトルとURLをコピーしました