Learn Python The Hard Way, 1st Edition的笔记(36)

按有用程度 按页码先后 最新笔记

  • 爱乐的陈 (昨日不可追,青春可追。)

    Rules For If-Statements 1.Every if-statement must have an else. 2.If this else should never be run because it doesn't make sense, then you must use a die function in the else that prints out an error message and dies, just like we did in the last exercise. This will find many errors. 3.Never nest if-statements more than 2 deep and always try to do them 1 deep. This means if you put an if in an ...

    2012-03-16 15:19:41   1人喜欢

  • 阿树

    你 的 class 应 该 使 用 “camel case(驼 峰 式 大 小 写)”,例 如 你 应 该 使 用SuperGoldFactory 而不是 super_gold_factory。 你的其他函数应该使用 “underscore format(下划线隔词),my_awesome_hair 而不是 myawesomehair 或者 MyAwesomeHair 。

    2013-10-06 11:44:56

  • 阿树

    Note: 井号有很多的英文名字,例如:’octothorpe(八角帽)’,’pound(英镑符)’,‘hash(电话的 # 键)’, ‘mesh(网)’ 等。

    2013-08-24 01:28:23

  • Charlene Jiang

    Steps for installing lpthw.web: 1. install setuptools from: http://pypi.python.org/pypi/setuptools#files 2. download and install pip from github: https://github.com/pypa/pip 3. install a web framework: sudo pip install lpthw.web Warning: Other Python programmers will warn you that lpthw.web is just a fork of another web framework called web.py, and that web.py has too much "magic". If they sa...   (2回应)

    2012-06-19 06:00:14

  • Charlene Jiang

    安装下面的软件包,我还没装好,都是众多Python程序员的汗水啊 1. pip – http://pypi.python.org/pypi/pip 2. distribute – http://pypi.python.org/pypi/distribute 3. nose – http://pypi.python.org/pypi/nose/ 4. virtualenv – http://pypi.python.org/pypi/virtualenv 注意: Do not just download these packages and install them by hand. Instead see how other people recommend you install these packages ...

    2012-06-14 08:07:29

  • Charlene Jiang

    Dictionary里可以保存函数,图一的map[next]是自定义的dict,图二的getattr(self, next)是一个类的所有方法的dict吧: 有两点很奇怪: 1. 为什么要用next = room()呢?直接room()不可以运行吗? 2. Class的声明也必须在括号里加一个object的参数,Class里的方法的声明里也要加一个self的参数。这个估计是python2的语法了,上次看a byte of python的时候,class的定义没这么罗嗦,那里是python3。

    2012-06-14 07:43:53

  • Charlene Jiang

    List!!! I like list in python 1. new_list = [x * 2 for x in my_list] 2. [[x+y for x in list_a] for y in list_b] 3. A further difference between map/filter and list comprehension, the latter is faster. List comprehension in Python can often provide a neat, clear, and concise syntax for creating lists from other lists. However, one should always be aware that, particularly for complex transformat...

    2012-06-13 06:31:08

  • Charlene Jiang

    // 取整? ** 指数,次幂? >>>>>>Keywords and del from not while as elif global or with assert else if pass yield break except import print class exec in raise continue finally is return def for lambda try >>>>>Data Types For data types, write out what makes up each one. For example, with strings write out how you create a string. For numbers write out a few numb...

    2012-06-11 21:43:33

  • Charlene Jiang

    1. underscore character 2. %s %d %r %f %e 3. print "-" , '-' , """-""" , '''-''' 4. # this is a comment 5. print "." * 10 6. \ (back-slash) character 7. raw_input("name? > ") 8. pydoc raw_input 9. open, file, os, and sys 10. from sys import argv 11. modules 12. open(filename, 'w') 13. file.read(), file.truncate(), file.close(), file.readline(), file.write(stuff), file.seek(offset) 14. ...

    2012-06-11 20:26:41

  • Charlene Jiang

    To fix an existing file: http://learnpythonthehardway.org/exercise26.txt 1. Definitions of methods should be ahead of file 2. Watch your indent Result: def break_words(stuff): """This function will break up words for us.""" words = stuff.split(' ') return words def sort_words(words): """Sorts the words.""" return sorted(words) def print_first_word(words): """Prints the first word after popping ...

    2012-06-11 20:15:05

<前页 1 2 3 4 后页>

笔记是你写在书页留白边上的内容;是你阅读中的批注、摘抄及随感。

笔记必须是自己所写,不欢迎转载。摘抄原文的部分应该进行特殊标明。

Learn Python The Hard Way, 1st Edition

>Learn Python The Hard Way, 1st Edition