- 1. pythonでExcel操作を自動化する
- 2. Windowsでpoetryが上手くインストールできない場合の対処
- 3. Python3 標準入力を辞書にする方法
- 4. PyScriptのすすめ
- 5. tensorflowがインストールできないだと!?
- 6. statsmodelsのseasonal_decomposeを活用した時系列データの可視化
- 7. CodeRunnerでpython: command not foundが出る場合
- 8. 【Pytorch】Transformerを実装する
- 9. 【Selenium】バージョン更新後のWarningについて
- 10. Pandas カスタム条件の関数でDataframeを比較する
- 11. [Python2 / Python3] python2 から python3 にアップデート / 移行した際のソース修正項目メモ
- 12. 【AtCoder解説】PythonでABC265のA,B,C,D,E問題を制する!
- 13. discordのイベント検知の方法
- 14. ローカル環境のStable Diffusionで大量に画像を生成して比較する
- 15. 【Python】陰陽座『廿弐匹目は毒蝮』をシミュレート
- 16. Stable DiffusionをGoogle Colaboratory上で動かして神絵ガチャを回してみる
- 17. 話題の Stable DiffusionをColabで作ってみた!
- 18. Python小技集 - #2 多次元リストの平坦化 (flatten)
- 19. ひたすら素数を生成するプログラムを書いてみた
- 20. ~/.python_history の場所を変更する
pythonでExcel操作を自動化する
openpyxlを使用して、seleniumで取得したデータをExcelへ入力する作業を自動化します。
csvに出力する等もあると思いますが、Excelはどこでも使っていると思うのでExcelを選びました。## インストール
openpyxlを以下でインストールします
“`bash
$ pip install openpyxl
“`インストール確認は以下です。
“`bash
$ pip list | grep openpyxl
openpyxl 3.0.10
“`## ファイル読み込み
“`python
import openpyxl
wb = openpyxl.load_workbook(“読み込みたいファイル”)
“`## シート読み込み
“`python
sheet = wb[“読み込みたいシート名”]
“`## セル読み込み
“`python
value = sheet.cell(row=1, column=1).value
“`A1セルを読み込む
row=行、column=列
“`python
Windowsでpoetryが上手くインストールできない場合の対処
いつも通りPowerShellからpoetryを入れようとしたら入らなくなってた
“`PS
PS C:\Users\hoge> (Invoke-WebRequest -Uri https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py -UseBasicParsing).Content | python –
Retrieving Poetry metadataThis installer is deprecated, and cannot install Poetry 1.2.0a1 or newer.
Additionally, Poetry installations created by this installer cannot `self update` to 1.2.0a1 or later.
You s
Python3 標準入力を辞書にする方法
先日、paizaラーニングのレベルアップ問題集で、連想配列の問題を解いていたときにでた疑問をまとめました。
https://paiza.jp/works/mondai/query_primer/query_primer__map_normal
(この練習問題の自分のコードも最後に載せてあります。)### python3 で 標準入力を辞書の形にする方法
まず、リストを作成し、そこに要素を順に入れていきます。
“`Python
list_dic = []for i in range(N):
list_dic.append(input().split())
“`
そして、“`dict()“`を使って辞書にします。“`Python
dictionary = dict(list_dic)
“`例:
標準入力
“`
1 Sin
2 Sakura
3 Kayo
4 Yui
“`コード
“`Python
mylist=[]for i in range(N):
mylist.append(input().split())mydict=d
PyScriptのすすめ
HTMLに直接Pythonが書ける画期的で革命的なライブラリのPyScriptについての情報を纏めます。
## 導入方法
ヘッダでJSライブラリをロードするだけです。
“`html