关卡编号:L0G2000
关卡名称:Python基础知识
闯关任务1:Leetcode 383(笔记中提交代码与leetcode提交通过截图)
闯关任务2:Vscode连接InternStudio debug笔记
任务1:Leetcode 383
题目:

解题代码:
class Solution(object):
def canConstruct(self, ransomNote, magazine):
"""
:type ransomNote: str
:type magazine: str
:rtype: bool
"""
char_count = {}
for char in magazine:
if char in char_count:
char_count[char] += 1
else:
char_count[char] = 1
for char in ransomNote:
if char in char_count and char_count[char]>0:
char_count[char] -= 1
else:
return False
return True
通过截图:

任务2:Vscode连接InternStudio debug笔记
发生错误的原因:输入函数json.loads不符合格式要求

debug所示的res变量:

修改成功后:

2043

被折叠的 条评论
为什么被折叠?



