Proxy環境下でpip[Python]

pip install hoge --proxy
データをopenするときの第2引数 r+, w+, a+の違いって何?[Python]

導入
“r+” と “w+” と “a+” における挙動の違い“r+” の場合
“w+” の場合
...
“r+” と “w+” と “a+” における挙動の違い“r+” の場合
“w+” の場合
...
Pythonでテキストファイルを1行ずつ読み込む[Python]

with open("text.txt") as f:for line in f:print(line)
withを使いたくなければ,
f = open("text.txt")for line in f:print(line)f. ...pd.read_csvでUnicodeDecodeErrorがでるときの対処法[Python][Pandas]

Windowsでpd.read_csvを使うと頻繁にエラーがでる.
エラーがでにくいcsvの読み込み方を見つけたので,メモ.
df = pd.read_csv("./hoge.csv", engine="python ...置換する文字を複数指定[Python]

import repatterns = "dog|cat|fox"repl = "animal"sentence = "dog, cat, fox, pen."re.sub(patterns, repl, sentence)>> ...
f'{hoge}’はフォーマット文字列リテラル(f-strings)[Python]

Kaggleを眺めていると見慣れない記法を発見。
x = str(x)for punct in puncts:x = x.replace(punct, f' {punct} ')return xん? f’ {p ...
MeCabで日本語の分かち書き[MeCab][Python]

import MeCabmecab = MeCab.Tagger ("-Owakati")print(mecab.parse("平成最後の初売りセールが開催中"))平成 最後 の 初 売り セール が 開催 中
OR
import ...Pythonでhtmlのファイルを読み込む方法[Python][Beautifulsoup]

from bs4 import BeautifulSoupimport relinks = []html_path = "./hoge.html"with open(html_path) as f:html = f.read()soup = ...
Pythonでテキストファイルから1行づつ読み込んで処理を行う[Python]

fname = "url.txt"with open(fname) as f:for line in f:contents = requests.get(line)time.sleep(1.5)
Pythonで範囲を指定して乱数を生成[Python][Numpy]

time.sleep(*) の変数をランダムに変えたかったときに使った方法を記す。
import numpy as npnp.random.randint(10, 20)>> 14ちなみに記法としては以下のよう ...