*disclaimer
120588
Python
Pythonの始め方
Pythonのサンプル
Tips
- パスを通しておく
- Windows の場合は、環境変数「TEMP」の「PATH」に、追加する
- 改行コードが問題になる場合があるので注意
Links
- PythonRecipe
- 処理の基本パターンが一覧になっていて便利
実行ファイルにする
pyinstaller
https://github.com/pyinstaller/pyinstaller/releases
- Python 3.7に対応
コマンドプロンプトで実行
pip install pyinstaller
- パイソンのスクリプトを書いておいて、
pyinstaller sample.py --onefile
とすると、「dist」というフォルダーができて、その中に、sample.exeファイルができる。
これで実行可能。
Windows
https://www.python.org/downloads/release/python-373/
Windows x86-64 executable installer
GUI
Tkinter
https://wiki.python.org/moin/TkInter
http://www.nct9.ne.jp/m_hiroi/light/py3tk01.html
Anaconda
Jupyter Notebook
CGI
文字コードをUTF-8に設定
/etc/httpd/conf/httpd.conf
<Directory "/var/www/cgi-bin"> # added below for Python SetEnv PYTHONIOENCODING utf-8
スクリプトの書き出し
#!/usr/bin/python3 # ヘッダー情報、テキストファイルを指定 print("Content-Type: text/plain; charset=utf-8\n")
Pythonの中からシェルスクリプトを呼び出す
- subprocessモジュール
import subprocess subprocess.call(["ls","-l"])
- コマンドラインは、半角スペース単位で、項目を別の要素として書いておく。
- References
https://dev.classmethod.jp/articles/python-subprocess-shell-command/
- SELinuxの設定
https://qiita.com/100/items/f7f43994568836b4a453
録音
- PyAudioを使う
References
https://watlab-blog.com/2019/06/20/pyaudio-record/
https://qiita.com/mix_dvd/items/adce7636e2ab33b25208
https://tips-memo.com/python-recording
https://algorithm.joho.info/programming/python/pyaudio-record/
http://sugiura-ken.org/wiki/