python

mongodb

 

こんな値

1575354984.412788

DB上は一応浮動小数点として扱われているようだ

ブラウザに渡してからPOSTして受け取った際にstringに変わっていた

見た目が同じなので全く気付かない

受け取ったときに忘れずキャストしよう

float(request.form['val'])

Robo3Tはなぜか丸めて表示されるので要注意

python

"selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 78"

こんな感じのエラー

ChromeDriverとChromeのバージョン違いらしい

ChromeDriverをダウングレード

 

pip install chromedriver-binary~=78.0.3904.105

 

参考サイト
https://qiita.com/H2O_HoriHori/items/ad7f9855cfc20b995c42
https://qiita.com/akiko-pusu/items/86faca0cb9c877896c04
http://chromedriver.chromium.org/downloads


jinja2

リストに連番を表示させたい

{% for comment in comments %}
<p>{{loop.index}} : {{comment}}</p>
{% endfor %}

loop.index0にすると0からになるようだ

https://jinja.palletsprojects.com/en/master/templates/#for


selenium

ページを取得できない

<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body></body></html>

こんな感じ

UAを変える、SSLやCAエラー無効等の設定変更で取得できたりできなかったり

最終的にChromeDriverとChromeのバージョンを上げたところ取得できるようになった

python

timestamp関係のメモ

print(str(time.time()) + "\n" + str(datetime.datetime.now().timestamp()))
1574129354.3799274
1574129354.379927

time.time()よりdatetime.datetime.now().timestamp()のほうがより正確

 

 

 

timestampをフォーマット

datetime.fromtimestamp(time.time()).strftime('%Y%m%d%H%M%S')
20191119113314

 

datetime.datetime.now().strftime('%Y%m%d%H%M%S')

最初からdatetimeならこれでも結果は同じ

python

 

iniファイルの読み込みエラー
configparser NoSectionError
実行したときのカレントディレクトリのiniファイルを読みに行く模様
絶対パスを指定するか、実行前にカレントディレクトリを移動してから実行すればおk