Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc8413bf

Browse files
authored
Merge pull requestwilfredinni#33 from Sonatrix/master
Merge two dictionaries
2 parentsab87bc8 +b1abbd6 commitc8413bf

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

‎blog_files/pysheet.md‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,6 +1225,22 @@ Using `setdefault` we could make the same code more shortly:
12251225
'w':2,
12261226
'y':1}
12271227
```
1228+
###Merge two dictionaries
1229+
1230+
```python
1231+
# in Python 3.5+:
1232+
>>> x= {'a':1,'b':2}
1233+
>>> y= {'b':3,'c':4}
1234+
>>> z= {**x,**y}
1235+
>>> z
1236+
{'c':4,'a':1,'b':3}
1237+
1238+
# in Python 2.7
1239+
>>> z=dict(x,**y)
1240+
>>> z
1241+
{'c':4,'a':1,'b':3}
1242+
```
1243+
12281244

12291245
##sets
12301246

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp