给定一个字符串，编写一个函数，该函数返回一个字典，其中键为字符串中的每个单词，值为其出现的次数。


def count_words(s):
    """
    :param s: A string
    :return: A dictionary where each key is a word in the string, and the value is the number of times the word appears
    """
    return ______
可以使用Python的字典来记录每个单词出现的次数，在字符串中先将所有非字母字符替换为空格，然后将结果按空格分割成单词列表，遍历列表并在字典中递增相应单词的出现次数即可。函数实现如下：

```python
def count_words(s):
    # Replace non-letter characters with spaces
    s = ''.join(c if c.isalpha() else ' ' for c in s)
    # Split string into words
    words = s.split()
    # Count occurrence of each word
    word_count = {}
    for word in words:
        if word in word_count:
            word_count[word] += 1
        else:
            word_count[word] = 1
    return word_count
```