Python

Thumbnail of post image 011

pip install hoge --proxy

Python

Thumbnail of post image 071

導入
“r+” と “w+” と “a+” における挙動の違い“r+” の場合
“w+” の場合
&# ...

Python

Thumbnail of post image 075

with open("text.txt") as f:for line in f:print(line)

withを使いたくなければ,

f = open("text.txt")for line in f:print(line)f. ...

Pandas,Python

Thumbnail of post image 144

Windowsでpd.read_csvを使うと頻繁にエラーがでる.

エラーがでにくいcsvの読み込み方を見つけたので,メモ.

df = pd.read_csv("./hoge.csv", engine="python ...

Python

Thumbnail of post image 174

import repatterns = "dog|cat|fox"repl = "animal"sentence = "dog, cat, fox, pen."re.sub(patterns, repl, sentence)>> ...

Python

Thumbnail of post image 044

Kaggleを眺めていると見慣れない記法を発見。

x = str(x)for punct in puncts:x = x.replace(punct, f' {punct} ')return x

ん? f’ {p ...

MeCab,Python

Thumbnail of post image 155

import MeCabmecab = MeCab.Tagger ("-Owakati")print(mecab.parse("平成最後の初売りセールが開催中"))平成 最後 の 初 売り セール が 開催 中

OR

import ...

Python

Thumbnail of post image 065

from bs4 import BeautifulSoupimport relinks = []html_path = "./hoge.html"with open(html_path) as f:html = f.read()soup = ...

Python

Thumbnail of post image 052

fname = "url.txt"with open(fname) as f:for line in f:contents = requests.get(line)time.sleep(1.5)

Numpy,Python

Thumbnail of post image 196

time.sleep(*) の変数をランダムに変えたかったときに使った方法を記す。

import numpy as npnp.random.randint(10, 20)>> 14

ちなみに記法としては以下のよう ...