Created
June 22, 2015 00:35
-
-
Save lichengwu/9de4fdea16cca710d40d to your computer and use it in GitHub Desktop.
字典默认值
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dt = {} | |
if "key" in dt: | |
dt["key"] = 1 | |
else: | |
dt["key"] += 1 | |
# 默认字典 | |
dt = collections.defaultdict(int) | |
dt["key"] += 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment