0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Python】エラー「unsupported operand type(s) for ** or pow(): 'str' and 'dict'」の原因

Posted at

概要

Pythonコードを動かしていたら以下のエラーになりました。

unsupported operand type(s) for ** or pow(): 'str' and 'dict'

原因

シンプルなミスでした。

エラーメッセージでは
**演算子に文字列と辞書は想定されていない」
と言われています。

**演算子が不適切な型に対して使用されたってことは、
複数のキーワード引数を指定した際に変数の型がおかしかったのかな?と
思って探してみるが特に問題はなく...

よくみると、原因は「,」の記入漏れでした。

        params = {
            'hogehoge' : hogehoge
            **self.SAMPLE_PARAMETERS
        }

        params = {
            'hogehoge' : hogehoge,
            **self.SAMPLE_PARAMETERS
        }

VSコード上では、上の方でも特に問題があるような波線などは出てきません。
一見すると分からないですね...

image.png

以上です!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?