次のようなdict関数を用いて文字列を辞書化するコードがある時、
引数に変数を用いるとエラーになってしまいます。
python
1tes = "__cd='d40000', ipip='2769419', dhash='3925fd', ss='dzze', eve='15671'" 2print(dict(tes))
結果
ValueError: dictionary update sequence element #0 has length 1; 2 is required
ただし、このように引数に変数を用いず、直接入力した時には上手くいきました。
python
1print(dict(__cd='d40000', ipip='2769419', dhash='3925fd', ss='dzze', eve='15671'))
結果
{'__cd': 'd40000', 'ipip': '2769419', 'dhash': '3925fd', 'ss': 'dzze', 'eve': '15671'}
引数に変数を用いる場合についてどう修正すべきか教えて下さい。

回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。