โ ๊ฐ์
python3.8 ํ๊ฒฝ์์ ์ฝ๋๋ฅผ ์คํ์ํค๋ ์๋์ ๊ฐ์ ์๋ฌ์ ํจ๊ป ์คํ์ด ์๋์๋ค
TypeError: 'type' object is not subscriptable
์ค๋ฅ๊ฐ ๋ฐ์ํ๋ ์ง์ ์ ๋ณด๋
def test_function1() -> list[str]:
...
def test_function2() -> dict:
ํ์ ํํธ๋ฅผ ์ง์ ํ ๋ ์๊ธฐ๋ ์ค๋ฅ
์์ธ์ ํ์ธํด๋ณด๋, typing ํํธ๋ python3.9๋ถํฐ ์ง์ํ๊ณ ์๋ค
โ ๋ฐฉ๋ฒ 1
์ฌ์ฉํ๋ python ์ 3.9๋ก ์ ๋ฐ์ดํธํ๋ ๋ฐฉ๋ฒ์ด ์๊ณ
โ ๋ฐฉ๋ฒ2
python typing ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ฌ์ฉํ์ฌ ์ง์ ํด์ฃผ๋ฉด ๋๋ค.
python ๋ฒ์ ์ ์ ํฐ ๋ง ๋จน๊ณ ํด์ผํ๋ ์ด ๋ฐฉ๋ฒ์ ๊ฐ์ถํ๋ค.
from typing import List, Dict
def test_function1() -> List[str]:
...
def test_function1() -> Dict:
...
โ ๊ฒฐ๊ณผ
์ ์งํ๋จ
'๐ฉ๐ปโ๐ป > python' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[python] Fastapi ์ ํ๋ฆฌ์ผ์ด์ exe ํ์ผ๋ก ๋ฐฐํฌํ๊ธฐ (0) | 2024.11.05 |
---|---|
[python] socket ๋์ ์ฐ๊ฒฐ (1) | 2024.10.22 |
[python] fastapi ์ค์๊ฐ ์คํธ๋ฆฌ๋ฐ ์ด๋ฏธ์ง ์ก์ถ (0) | 2024.10.21 |
[python] Received response with content-encoding: gzip, but failed to decode it. (0) | 2024.02.19 |
[python] ๋ค์ด๋ฒ ์นดํ ํฌ๋กค๋ง (1) | 2024.01.30 |