我正在努力学习 Python。考虑一下 C 中的这个简单的字谜检查器:
bool are_anagrams(const char* str1, const char* str2)
{
int str1_count[NUM_CHARS] = {0};
int str2_count[NUM_CHARS] = {0};
for(int i = 0; i < strlen(str1); i++)
{
str1_count[str1[i] - 'a']++;
}
for(int i = 0; i < strlen(str2); i++)
{
str2_count[str2[i] - 'a']++;
}
for(int i = 0; i < NUM_CHARS; i++)
{
if(str1_count[i] != str2_count[i])
{ return false; }
}
return true;
}
具体来说,这行是如何str1_count[str2[i] - 'a']++
在 Python 中完成的?