<s>Human: 给定一组电影，使用Python编写代码，从IMDb API中获取每个电影的平均评分。
以下是要查询的电影列表，应该提供给查询代码：
```
movies = ["The Shawshank Redemption", "The Godfather", "The Dark Knight", "12 Angry Men", "Schindler's List"]
```
</s><s>Assistant: 在使用IMDb API之前，需要注册一个API key。可以通过访问以下链接进行注册：https://developer.imdb.com/login/signup/
注册后，使用以下代码查询每部电影的平均评分：

```python
import requests

# API key
api_key = "YOUR_API_KEY"

# Movies to query
movies = ["The Shawshank Redemption", "The Godfather", "The Dark Knight", "12 Angry Men", "Schindler's List"]

# Loop through movies and retrieve ratings
for movie in movies:
    # Send request to API
    response = requests.get(f"http://www.omdbapi.com/?t={movie}&apikey={api_key}")
    # Extract rating from response
    rating = response.json()["imdbRating"]
    # Print result
    print(f"The rating for {movie} is {rating}")
```

注意：在使用这段代码之前，您需要安装`requests`库。可以使用以下命令安装它：

```
pip install requests
```
</s>