python flask 環境において、google ads.txt を設置する方法 flask python
python flask 環境において、google adsense で使用する ads.txt を設置する方法
1 ads.txt ファイルの設置
./{プロジェクト}/html/static/ads.txt 箇所に配置
2 app.py に send_from_direct() を利用して、ads.txt を参照するよう以下を追加
-----------------------
python flask環境で cacheを使用するため設定 Flask-Caching python
python flask環境で cacheを使用するため設定
docker環境での設定
■1 Flask-Caching のインストール
dockerを使用してるので Dockerfileに以下を追加
RUN pip install Flask-Caching
■2 app.py に flask_caching の設定
from flask_caching impor
ImportError: cannot import name 'TypeAliasType' from 'typing_extensions' (/usr/local/lib/python3.7/site-packages/typing_extensions.py)のエラーがでてたけど python python
ImportError: cannot import name 'TypeAliasType' from 'typing_extensions' (/usr/local/lib/python3.7/site-packages/typing_extensions.py)のエラーがでてたけど
pip install fastapi-sqlalchemy
をいれなおしたらでなくなった
pyth
pythonでコマンドを実行し結果を返値で取得 python python
pythonでコマンドを実行し結果を返値で取得
import subprocess
r=subprocess.run("ls", capture_output=True, text=True).stdout
# Python 3.7以降限定 capture_output=True , Python 3.6以前は代わりにstdout=subprocess.PIPE と stderr
Pythonでは文字列や数値の右にゼロを詰める(ゼロパディング)する場合、zfill関数を使うと便利 python python
Pythonでは文字列や数値の右にゼロを詰める(ゼロパディング)する場合、zfill関数を使うと便利
例)
s = "c"
print( s.zfill( 2 ))
print( s.zfill( 8 ))
#0c
#0000000c