Pythonでstrとlistを相互変換してみた

なんかsqlite使ってたらリストをsqliteに流し込めないっぽかったのでPythonでstrとlistを相互変換してみた話です。

 

基本的にはこんな感じでいいと思います。一応やってることを説明しておくとlist_to_strではリストの要素を全部繋げて(join()して)要素の間に;をはさんであげてるだけです。

でstr_to_listでは逆に;で区切ったものをリスト化(split)してるだけです。

Comments

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Fatal error: Uncaught wfWAFStorageFileException: Unable to save temporary file for atomic writing. in /var/www/html/wp-content/plugins/wordfence/vendor/wordfence/wf-waf/src/lib/storage/file.php:34 Stack trace: #0 /var/www/html/wp-content/plugins/wordfence/vendor/wordfence/wf-waf/src/lib/storage/file.php(658): wfWAFStorageFile::atomicFilePutContents('/var/www/html/w...', 'saveConfig('livewaf') #2 {main} thrown in /var/www/html/wp-content/plugins/wordfence/vendor/wordfence/wf-waf/src/lib/storage/file.php on line 34