各种资料汇总 方便以后查用
Python基础知识
中文
https://zhuanlan.zhihu.com/p/20878530?refer=intelligentunit
英文
http://cs231n.github.io/python-numpy-tutorial/
课程笔记翻译
https://blog.csdn.net/zhuimengshaonian66/article/details/81736550
第一次作业 环境设置
https://blog.csdn.net/u014485485/article/details/79433514
第一次作业 详解
https://blog.csdn.net/zhangxb35/article/details/55223825
李飞飞CS231n课程-中文笔记(包括课后作业要求)翻译汇总
课程连接
https://blog.csdn.net/CV_YOU/article/details/77888010
2017
https://study.163.com/forum/index.htm?cid=1004697005&p=2
2016
def quicksort(arr):
if len(arr) <= 1:
return arr
pivot = arr[len(arr)/2]
left = [x for x in arr if x< pivot]
middle = [x for x in arr if x == pivot]
right = [x for x in arr if x > pivot]
return quicksort(left) + middle + quicksort(right)
print quicksort([3,6,8,10,1,2,1])
Note that unlike many languages, Python does not have unary increment (x++) or decrement (x- -) operators
print(xs[-1]) # Negative indices count from the end of the list; prints "2"
xs = [3, 1, 2]
xs[2] = 'foo' # Lists can contain elements of different types
print(xs) # Prints "[3, 1, 'foo']"
>>> xs.append("bar")
>>> print(xs)
[3, 2, 1, 'bar']
enumerate 枚举 第一个参数默认为 int 第二个参数默认为 String
animals = ['cat', 'dog', 'monkey']
for idx, animal in enumerate(animals):
print '#%d: %s' % (idx + 1, animal)
Dictionary
print d.get('monkey', 'N/A') # Get an element with a default; prints "N/A"
>>> d={"person":2,"cat":4,"spider":8}
>>> for x in d:
... print(x)
... print(d[x])
/*person
2
spider
8
cat
4*/
for animal in d:
legs = d[animal]
print 'A %s has %d legs' % (animal, legs)
# Prints "A person has 2 legs", "A spider has 8 legs", "A cat has 4 legs"
存疑 输出的排序问题( cat 排第二 却是最后输出)
d = {'person': 2, 'cat': 4, 'spider': 8}
for animal, legs in d.iteritems():
print 'A %s has %d legs' % (animal, legs)
# Prints "A person has 2 legs", "A spider has 8 legs", "A cat has 4 legs"