Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
datetime.time オブジェクトで表される、時間でいっぱいのドロップダウンを持つフォームがあります。
オブジェクトをシリアル化する最良の方法は何ですか? 例えば:
<option value="${time.serialize()}">${time.isoformat()}</option>
そして、反対側でそれを逆シリアル化しますか? 例えば:
time = datetime.time.deserialize(request.params['time'])
オブジェクトの場合repr、datetime.timePython は を返しますisoformat。reprs はオブジェクトのシリアル化されたバージョンになろうとするため、これは使用すべき値であることを示しています。
repr
datetime.time
isoformat
import datetime timestring = datetime.datetime.now().time().isoformat() timeobj = datetime.datetime.strptime(timestring, "%H:%M:%S.%f").time()