|
2 | 2 | "metadata": {
|
3 | 3 | "celltoolbar": "Slideshow",
|
4 | 4 | "name": "",
|
5 |
| - "signature": "sha256:b40fd47c55e8070830538cdd83933a172f70802dac44eb4836a43e3de5d7221e" |
| 5 | + "signature": "sha256:7ca92165037692606a3b404d1d2be3afacf7a5404c7a038c1ed44ebf258f9fc8" |
6 | 6 | },
|
7 | 7 | "nbformat": 3,
|
8 | 8 | "nbformat_minor": 0,
|
|
2464 | 2464 | "output_type": "stream",
|
2465 | 2465 | "stream": "stdout",
|
2466 | 2466 | "text": [
|
2467 |
| - "-rw-r--r-- 1 shell shell 111 10\u6708 28 20:00 testmod.py\r\n" |
| 2467 | + "-rw-r--r-- 1 shell shell 111 10\u6708 28 20:06 testmod.py\r\n" |
2468 | 2468 | ]
|
2469 | 2469 | }
|
2470 | 2470 | ],
|
|
2643 | 2643 | "output_type": "stream",
|
2644 | 2644 | "stream": "stdout",
|
2645 | 2645 | "text": [
|
2646 |
| - "-rw-r--r-- 1 shell shell 111 10\u6708 28 20:00 testmod.py\r\n", |
2647 |
| - "-rw-r--r-- 1 shell shell 333 10\u6708 28 20:00 testmod.pyc\r\n" |
| 2646 | + "-rw-r--r-- 1 shell shell 111 10\u6708 28 20:06 testmod.py\r\n", |
| 2647 | + "-rw-r--r-- 1 shell shell 333 10\u6708 28 20:06 testmod.pyc\r\n" |
2648 | 2648 | ]
|
2649 | 2649 | }
|
2650 | 2650 | ],
|
|
3937 | 3937 | "output_type": "stream",
|
3938 | 3938 | "stream": "stdout",
|
3939 | 3939 | "text": [
|
3940 |
| - "<__main__.Person instance at 0x7f2bac0b0128>\n" |
| 3940 | + "<__main__.Person instance at 0x7f7fbc419128>\n" |
3941 | 3941 | ]
|
3942 | 3942 | }
|
3943 | 3943 | ],
|
|
4848 | 4848 | "output_type": "stream",
|
4849 | 4849 | "stream": "stdout",
|
4850 | 4850 | "text": [
|
4851 |
| - "-rw-r--r-- 1 shell shell 95 10\u6708 28 20:00 poem.txt\r\n" |
| 4851 | + "-rw-r--r-- 1 shell shell 95 10\u6708 28 20:07 poem.txt\r\n" |
4852 | 4852 | ]
|
4853 | 4853 | }
|
4854 | 4854 | ],
|
|
4883 | 4883 | "\u4ee5\u4e0a\u7686\u662flinux\u6307\u4ee4\uff0c\u56e0\u6b64\u4e0d\u80fd\uff08\u4e5f\u4e0d\u9700\u8981\uff09\u5728windows\u4e0a\u6267\u884c\u3002windows\u4e0a\u5bf9\u5e94\u7684\u884c\u4e3a\u4e3adir\uff0ctype\uff0c\u548cdel\u3002"
|
4884 | 4884 | ]
|
4885 | 4885 | },
|
4886 |
| - { |
4887 |
| - "cell_type": "markdown", |
4888 |
| - "metadata": { |
4889 |
| - "slideshow": { |
4890 |
| - "slide_type": "subslide" |
4891 |
| - } |
4892 |
| - }, |
4893 |
| - "source": [ |
4894 |
| - "## with\n", |
4895 |
| - "\n", |
4896 |
| - "with\u53ef\u4ee5\u5728\u63a8\u51fa\u533a\u5757\u65f6\u81ea\u52a8\u5173\u95ed\u6587\u4ef6\uff0c\u800c\u4e14\u5bf9\u5f02\u5e38\u5b89\u5168\uff08\u5f02\u5e38\u5728\u4e0b\u4e00\u8282\u8bb2\uff09\u3002\n", |
4897 |
| - "\n", |
4898 |
| - "with\u4e0d\u4ec5\u53ef\u4ee5\u7528\u4e8e\u6587\u4ef6\uff0c\u800c\u4e14\u53ef\u4ee5\u7528\u4e8e\u5f88\u591a\u9700\u8981\u5728\u79bb\u5f00\u533a\u57df\u65f6\u81ea\u52a8\u5173\u95ed\u7684\u5bf9\u8c61\uff0c\u4f8b\u5982\u9501\u3002" |
4899 |
| - ] |
4900 |
| - }, |
4901 |
| - { |
4902 |
| - "cell_type": "code", |
4903 |
| - "collapsed": false, |
4904 |
| - "input": [ |
4905 |
| - "import sys\n", |
4906 |
| - "with open(\"poem.txt\") as f:\n", |
4907 |
| - " for line in f:\n", |
4908 |
| - " sys.stdout.write(line)" |
4909 |
| - ], |
4910 |
| - "language": "python", |
4911 |
| - "metadata": { |
4912 |
| - "slideshow": { |
4913 |
| - "slide_type": "-" |
4914 |
| - } |
4915 |
| - }, |
4916 |
| - "outputs": [ |
4917 |
| - { |
4918 |
| - "output_type": "stream", |
4919 |
| - "stream": "stdout", |
4920 |
| - "text": [ |
4921 |
| - "Programming is fun\n", |
4922 |
| - "When the work is done\n", |
4923 |
| - "if you wanna make your work also fun:\n", |
4924 |
| - " use Python!\n" |
4925 |
| - ] |
4926 |
| - } |
4927 |
| - ], |
4928 |
| - "prompt_number": 111 |
4929 |
| - }, |
4930 |
| - { |
4931 |
| - "cell_type": "code", |
4932 |
| - "collapsed": false, |
4933 |
| - "input": [ |
4934 |
| - "!rm -f poem.txt" |
4935 |
| - ], |
4936 |
| - "language": "python", |
4937 |
| - "metadata": { |
4938 |
| - "slideshow": { |
4939 |
| - "slide_type": "skip" |
4940 |
| - } |
4941 |
| - }, |
4942 |
| - "outputs": [], |
4943 |
| - "prompt_number": 112 |
4944 |
| - }, |
4945 | 4886 | {
|
4946 | 4887 | "cell_type": "markdown",
|
4947 | 4888 | "metadata": {
|
|
4996 | 4937 | "output_type": "pyerr",
|
4997 | 4938 | "traceback": [
|
4998 | 4939 | "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
|
4999 |
| - "\u001b[0;32m<ipython-input-113-4a9fe39e6a16>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mPrint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Hello World\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", |
| 4940 | + "\u001b[0;32m<ipython-input-111-4a9fe39e6a16>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mPrint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Hello World\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", |
5000 | 4941 | "\u001b[0;31mNameError\u001b[0m: name 'Print' is not defined"
|
5001 | 4942 | ]
|
5002 | 4943 | }
|
5003 | 4944 | ],
|
5004 |
| - "prompt_number": 113 |
| 4945 | + "prompt_number": 111 |
5005 | 4946 | },
|
5006 | 4947 | {
|
5007 | 4948 | "cell_type": "code",
|
|
5020 | 4961 | ]
|
5021 | 4962 | }
|
5022 | 4963 | ],
|
5023 |
| - "prompt_number": 114 |
| 4964 | + "prompt_number": 112 |
5024 | 4965 | },
|
5025 | 4966 | {
|
5026 | 4967 | "cell_type": "markdown",
|
|
5036 | 4977 | "\n",
|
5037 | 4978 | "\u5f02\u5e38\u8f93\u51fa\u901a\u5e38\u548c\u51fd\u6570\u7684\u8c03\u7528\u987a\u5e8f\u76f8\u540c\uff0c\u548c\u6808\u7684\u987a\u5e8f\u76f8\u53cd\u3002\n",
|
5038 | 4979 | "\n",
|
5039 |
| - "\u6700\u4e0a\u5c42\u7684\u8c03\u7528\uff08\u6700\u5148\u53d1\u751f\u7684\uff09\u5728\u6700\u4e0a\u9762\uff0c\u6700\u540e\u6267\u884c\u5230\u7684\u5730\u65b9\u5728\u6700\u4e0b\u9762\u3002\u6700\u540e\u4e00\u4e2a\u5f02\u5e38\u884c\u5c31\u662f\u4e00\u573a\u53d1\u751f\u7684\u7cbe\u786e\u5730\u70b9\u3002\n", |
| 4980 | + "\u6700\u4e0a\u5c42\u7684\u8c03\u7528\uff08\u6700\u5148\u53d1\u751f\u7684\uff09\u5728\u6700\u4e0a\u9762\uff0c\u6700\u540e\u6267\u884c\u5230\u7684\u5730\u65b9\u5728\u6700\u4e0b\u9762\u3002\u6700\u540e\u4e00\u4e2a\u5f02\u5e38\u884c\u5c31\u662f\u5f02\u5e38\u53d1\u751f\u7684\u7cbe\u786e\u5730\u70b9\u3002\n", |
5040 | 4981 | "\n",
|
5041 | 4982 | "\u6700\u540e\u4e00\u884c\u662f\u5f02\u5e38\u7684\u540d\u5b57\u548c\u53c2\u6570\u3002"
|
5042 | 4983 | ]
|
|
5077 | 5018 | "output_type": "pyerr",
|
5078 | 5019 | "traceback": [
|
5079 | 5020 | "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[0;31mException\u001b[0m Traceback (most recent call last)",
|
5080 |
| - "\u001b[0;32m<ipython-input-115-22bfd87adf46>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 8\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 9\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 10\u001b[0;31m \u001b[0;32mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mlayer1\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", |
5081 |
| - "\u001b[0;32m<ipython-input-115-22bfd87adf46>\u001b[0m in \u001b[0;36mlayer1\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mlayer1\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0;32mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'layer1 called'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 3\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mlayer2\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 4\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mlayer2\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", |
5082 |
| - "\u001b[0;32m<ipython-input-115-22bfd87adf46>\u001b[0m in \u001b[0;36mlayer2\u001b[0;34m()\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mlayer2\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 6\u001b[0m \u001b[0;32mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'layer2 called'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 7\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mException\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'arg1'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 8\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 9\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", |
| 5021 | + "\u001b[0;32m<ipython-input-113-22bfd87adf46>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 8\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 9\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 10\u001b[0;31m \u001b[0;32mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mlayer1\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", |
| 5022 | + "\u001b[0;32m<ipython-input-113-22bfd87adf46>\u001b[0m in \u001b[0;36mlayer1\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mlayer1\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0;32mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'layer1 called'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 3\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mlayer2\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 4\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mlayer2\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", |
| 5023 | + "\u001b[0;32m<ipython-input-113-22bfd87adf46>\u001b[0m in \u001b[0;36mlayer2\u001b[0;34m()\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mlayer2\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 6\u001b[0m \u001b[0;32mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'layer2 called'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 7\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mException\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'arg1'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 8\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 9\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", |
5083 | 5024 | "\u001b[0;31mException\u001b[0m: ('arg1', 2)"
|
5084 | 5025 | ]
|
5085 | 5026 | }
|
5086 | 5027 | ],
|
5087 |
| - "prompt_number": 115 |
| 5028 | + "prompt_number": 113 |
5088 | 5029 | },
|
5089 | 5030 | {
|
5090 | 5031 | "cell_type": "markdown",
|
|
5144 | 5085 | ]
|
5145 | 5086 | }
|
5146 | 5087 | ],
|
5147 |
| - "prompt_number": 116 |
| 5088 | + "prompt_number": 114 |
5148 | 5089 | },
|
5149 | 5090 | {
|
5150 | 5091 | "cell_type": "markdown",
|
|
5203 | 5144 | ]
|
5204 | 5145 | }
|
5205 | 5146 | ],
|
5206 |
| - "prompt_number": 117 |
| 5147 | + "prompt_number": 115 |
5207 | 5148 | },
|
5208 | 5149 | {
|
5209 | 5150 | "cell_type": "markdown",
|
|
5231 | 5172 | "language": "python",
|
5232 | 5173 | "metadata": {},
|
5233 | 5174 | "outputs": [],
|
5234 |
| - "prompt_number": 118 |
| 5175 | + "prompt_number": 116 |
5235 | 5176 | },
|
5236 | 5177 | {
|
5237 | 5178 | "cell_type": "code",
|
|
5271 | 5212 | ]
|
5272 | 5213 | }
|
5273 | 5214 | ],
|
5274 |
| - "prompt_number": 119 |
| 5215 | + "prompt_number": 117 |
5275 | 5216 | },
|
5276 | 5217 | {
|
5277 | 5218 | "cell_type": "markdown",
|
|
5330 | 5271 | ]
|
5331 | 5272 | }
|
5332 | 5273 | ],
|
| 5274 | + "prompt_number": 118 |
| 5275 | + }, |
| 5276 | + { |
| 5277 | + "cell_type": "markdown", |
| 5278 | + "metadata": { |
| 5279 | + "slideshow": { |
| 5280 | + "slide_type": "subslide" |
| 5281 | + } |
| 5282 | + }, |
| 5283 | + "source": [ |
| 5284 | + "## with\n", |
| 5285 | + "\n", |
| 5286 | + "with\u53ef\u4ee5\u5728\u63a8\u51fa\u533a\u5757\u65f6\u81ea\u52a8\u5173\u95ed\u6587\u4ef6\uff0c\u800c\u4e14\u5bf9\u5f02\u5e38\u5b89\u5168\uff08\u5f02\u5e38\u5728\u4e0b\u4e00\u8282\u8bb2\uff09\u3002\n", |
| 5287 | + "\n", |
| 5288 | + "with\u4e0d\u4ec5\u53ef\u4ee5\u7528\u4e8e\u6587\u4ef6\uff0c\u800c\u4e14\u53ef\u4ee5\u7528\u4e8e\u5f88\u591a\u9700\u8981\u5728\u79bb\u5f00\u533a\u57df\u65f6\u81ea\u52a8\u5173\u95ed\u7684\u5bf9\u8c61\uff0c\u4f8b\u5982\u9501\u3002" |
| 5289 | + ] |
| 5290 | + }, |
| 5291 | + { |
| 5292 | + "cell_type": "code", |
| 5293 | + "collapsed": false, |
| 5294 | + "input": [ |
| 5295 | + "import sys\n", |
| 5296 | + "with open(\"poem.txt\") as f:\n", |
| 5297 | + " for line in f:\n", |
| 5298 | + " sys.stdout.write(line)" |
| 5299 | + ], |
| 5300 | + "language": "python", |
| 5301 | + "metadata": { |
| 5302 | + "slideshow": { |
| 5303 | + "slide_type": "-" |
| 5304 | + } |
| 5305 | + }, |
| 5306 | + "outputs": [ |
| 5307 | + { |
| 5308 | + "output_type": "stream", |
| 5309 | + "stream": "stdout", |
| 5310 | + "text": [ |
| 5311 | + "Programming is fun\n", |
| 5312 | + "When the work is done\n", |
| 5313 | + "if you wanna make your work also fun:\n", |
| 5314 | + " use Python!\n" |
| 5315 | + ] |
| 5316 | + } |
| 5317 | + ], |
| 5318 | + "prompt_number": 119 |
| 5319 | + }, |
| 5320 | + { |
| 5321 | + "cell_type": "code", |
| 5322 | + "collapsed": false, |
| 5323 | + "input": [ |
| 5324 | + "!rm -f poem.txt" |
| 5325 | + ], |
| 5326 | + "language": "python", |
| 5327 | + "metadata": { |
| 5328 | + "slideshow": { |
| 5329 | + "slide_type": "skip" |
| 5330 | + } |
| 5331 | + }, |
| 5332 | + "outputs": [], |
5333 | 5333 | "prompt_number": 120
|
5334 | 5334 | },
|
5335 | 5335 | {
|
|
0 commit comments