python

csvからコード生成

PythonでCSVファイルを読み込み・書き込み(入力・出力) | note.nkmk.me import csv import pprint with open('register_list2.csv') as f: reader = csv.reader(f) for row in reader: if row[0] =="wr": print("CMD.wrW(mst,"+row[4]+" + "+row[5]+","+ro…

visual studio code設定

www.atmarkit.co.jp

仮想環境の設定

venvで仮想環境の作り方。 venvは最新のpythonなら元々入っている。 qiita.com 仮想環境用のフォルダを決めて、そこに複数の環境を置いておけばよいみたい。 仮想環境用のフォルダを↓の通り指定すると、 vscodeから切り替えができる。 仮想環境は作ると、ラ…

最小限のライブラリ環境メモ

python 3.7.4 64bit環境にて PYPIのorgからダウンロードするwhlファイル名 numpy-1.17.2-cp37-cp37m-win_amd64.whl (12.8 MB) Pillow-6.1.0-cp37-cp37m-win_amd64.whl (2.0 MB) pylint-2.3.1-py3-none-any.whl (765.2 kB) mccabe-0.6.1-py2.py3-none-any.whl…

環境の移行関連

オンライン環境で、すでにあるライブラリ環境を移行する場合はこれ↓ a-zumi.net ライブラリをまとめてアンインストールする方法↓ www.lifewithpython.com ライブラリの依存関係を調べる e-tec-memo.herokuapp.com オンライン環境でダウンロードしたライブラ…

ファイル名取得

os.path glob

配列の抽出

test

2つの画像のマージ

# 2つの4x8画像を1列ごとに入れ子にして8x8を作る。 1次元行列 → vstack → 軸入れ替え → 2次元行列、でやってます。 import numpy as np from PIL import Image # make array a = np.arange(32).astype(np.uint8).reshape(4,8)*8 b = a+128 # x =a.r…

tkinterひな形その2

-*- coding: utf8 -*- import os import sys import tkinter as tk import tkinter.filedialog as tkFD import tkinter.messagebox as tkmsg files = '' def FileTransExec(event): msgtxt ='' for row in files: msgtxt += row msgtxt +='\n' print (msgtxt…

tkinterひな形その1

PythonのTkinterを使ってみる - Qiita ↑参考にしました。 ファイル指定、パラメータ指定、して、実行。 みたいなアプリのイメージ。 # -*- coding: utf8 -*- import os import sys import tkinter as tk import tkinter.filedialog as tkFD import tkinter.m…

ファイルの連結

https://torina.top/detail/268/ import shutil with open('output_file.txt','wb') as wfd: for f in ['test1.txt','test2.txt','test3.txt']: with open(f,'rb') as fd: shutil.copyfileobj(fd, wfd) #1024102410) #10MB per writing chunk to avoid readi…

ファイルパスの取得

Pythonでフォルダ内のファイルリストを取得する - Qiita pathlibをつかうのがいいみたい。

pillowでtifファイル保存時に圧縮する。

Image.save as tiff image, and the compression parameter does not work · Issue #2866 · python-pillow/Pillow · GitHub from PIL import Image from PIL import features print(features.check('libtiff')) pilim.save('test_re0903_comp.tif',compressi…

ライブラリの依存関係を調べるpipdeptree

blog.amedama.jp ちなみにpyinstaller は以下。 PyInstaller==3.3.1 - future [required: Any, installed: 0.16.0] - macholib [required: >=1.8, installed: 1.9] - altgraph [required: >=0.15, installed: 0.15] - pefile [required: >=2017.8.1, install…

exeファイル変換

python実行ファイル変換モジュール比較2 - Qiita N@i.jp qiita.com WindowsでPythonにcx_Freezeをインストールする - batch-file - python-3.x | CODE Q&A [日本語] ・pip install だけだと、cxfreeze-quickstartが使えなくて。*.batをつくると、実行できる…

version2と3の使い分け

Python2.7 と Python3.3 を Windows で併用する | ユニマージュ

ライブラリのリスト

astroid (1.5.3) bleach (2.0.0) colorama (0.3.9) cx-Freeze (5.0.2) cycler (0.10.0) decorator (4.1.2) entrypoints (0.2.3) html5lib (0.999999999) ipykernel (4.6.1) ipython (6.1.0) ipython-genutils (0.2.0) ipywidgets (7.0.0) isort (4.2.15) jed…

numpyでバイナリ読み込み

from PIL import Image import numpy as np バイナリファイルから読みこみ file_name='test_bin.bin' bin_arr = np.fromfile(file_name, dtype='uint8').reshape(4,16) print(bin_arr.shape) plt.imshow(bin_arr) image.show(command='display -quiet')

pillow

pc.atsuhiro-me.net Python 3.5 対応画像処理ライブラリ Pillow (PIL) の使い方 - Librabuch