CV2016 231n李飞飞

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

https://study.163.com/note/noteIndex.htm?id=1003223001&type=0#/noteIndex?resType=2&resId=1003223001&sortType=0

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"
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值