Skip to content

Commit 2c610ea

Browse files
committed
enchance and add dictionary
1 parent d2b0242 commit 2c610ea

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,15 @@
1212
* http://ssv.sebug.net/Python_Coding_Rule
1313

1414
## 学习资源
15+
### 中文资源
1516
* [简明 Python 教程](http://sebug.net/paper/python/index.html)
17+
* [Python 手册](http://sebug.net/paper/books/python_hb/)
18+
* [ 深入 Python :Dive Into Python 中文版](http://sebug.net/paper/books/dive-into-python/)
1619
* [crossin的编程教室](http://crossin.me/forum.php?mod=forumdisplay&fid=2)
20+
* [深入 Python 3](http://sebug.net/paper/books/dive-into-python3/)
21+
* [Python安全](http://sebug.net/paper/books/vulncat/python/)
22+
23+
### 英文资源
1724
* [dive into python](http://www.diveintopython.net/toc/index.html)
1825
* [learn python the hardway](http://learnpythonthehardway.org/book/)
1926
* [python官网教程](https://docs.python.org/2/tutorial/)

dictionary.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/python
2+
#coding:utf-8
3+
hehe = '123';
4+
obj = {'name': 'joel', 'sex': 'male', hehe: 'just hehe'};# 键值在创建时就可以是变量,这个比js强大
5+
obj['age'] = 18;
6+
other = 'otherMsg';
7+
obj[other] = 'he is so cool!'; # worked~ like javascript
8+
9+
for key,value in obj.items():
10+
print key + ' is ' + str(value);# str() 将 int转化为str

list.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@
1313
for i in range(10):
1414
arr.append(i);
1515

16+
# 遍历时需要读取下标 enumerate
17+
for index, value in enumerate(['a', 'b', 'c']):
18+
print 'index: %s, value: %s'% (index, value);
19+
20+
# 同时遍历两个或多个数组
21+
for first, second in zip(['f_a', 'f_b'], ['s_a', 's_b']):
22+
print 'first: %s, second: %s'%(first, second);
23+
1624
# 删除列表中下标为参数的值
1725
arr.pop(3);
1826
arr.pop(0);

tuple.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
b = 1, 3, (3, 5); # 可嵌套
1010
print b;
1111

12-
# 元组的封装的逆操作
12+
# 序列拆封
1313
a = 3;
1414
b = 4;
1515
a, b = (b,a);
@@ -19,4 +19,7 @@ def triple(x, y, z):
1919
return (3 * x, 3 * y, 3 * z);
2020

2121
a, b, c = triple(1, 2, 3);
22-
print a, b, c; #3, 6, 9
22+
print a, b, c; #3, 6, 9
23+
24+
a, b, c = 1, 2, 3;
25+
print a, b, c; #1, 2, 3

0 commit comments

Comments
 (0)