![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
启铭
这个作者很懒,什么都没留下…
展开
-
raw_input() 与 input() __ Python
raw_input() 与 input() __ Python 这两个均是 python 的内建函数,通过读取控制台的输入与用户实现交互。但他们的功能不尽相同。举两个小例子。 1 >>> raw_input_A = raw_input("raw_input: ") 2 raw_input: abc 3 >>> input_A = input("Input: ") 4 Input: abc转载 2017-12-04 11:04:23 · 126 阅读 · 0 评论 -
笨办法学Python习题35-加分习题
加分习题 1. 把这个游戏的地图画出来,把自己的路线也画出来。 2. 改正你所有的错误,包括拼写错误。 3. 为你不懂的函数写注解。记得文档注解该怎么写吗? 4. 为游戏添加更多元素。通过怎样的方式可以简化并且扩展游戏的功能呢? 5. 这个 gold_room 游戏使用了奇怪的方式让你键入一个数字。这种方式会导致什么样的 bug? 你可以用比检查 0、1 更好的方式判断输入是否是数字吗?原创 2017-12-28 18:49:44 · 1641 阅读 · 0 评论 -
笨办法学Python习题33加分题
i = 0numbers = []while i < 6: print "At the top i is %d" % i numbers.append(i) i = i + 1 print "Numbers now: ", numbers print "At the bottom i is %d" % iprint原创 2017-12-28 14:37:47 · 1716 阅读 · 2 评论 -
17个新手常见Python运行时错误
当初学 Python 时,想要弄懂 Python 的错误信息的含义可能有点复杂。这里列出了常见的的一些让你程序 crash 的运行时错误。 1)忘记在 if , elif , else , for , while , class ,def 声明末尾添加 :(导致 “SyntaxError :invalid syntax”) 该错误将发生在类似如下代码中:if spam == 42 pr转载 2017-12-19 11:11:36 · 281 阅读 · 0 评论 -
Python学习笔记之符号
1.# 井号有很多的英文名字,例如:’octothorpe(八角帽)’,’pound(英镑符)’, ‘hash(电话的#键)’,‘mesh(网)’ 等。 2. ^caret 3. ” double-quote双引号原创 2017-12-19 11:06:58 · 217 阅读 · 0 评论 -
Python学习笔记之报错整理
1.如果你来自另外一个国家,而且你看到关于 ASCII 编码的错误,那就在你的 python 脚本的最上面加入 这一行:# -*- coding: utf-8 -*-这样你就在脚本中使用了 unicode UTF-8 编码,这些错误就不会出现了。原创 2017-12-19 09:58:10 · 199 阅读 · 0 评论 -
MacBook安装yaml
0.缘起: 遇到报错 ImportError: No module named yaml 尝试安装 sudo easy_install pyyaml 一直卡住。。。 ————————–分割线——————————- 解决方案: 1.下载yaml http://pyyaml.org/wiki/PyYAML 我用的MacBook 下载包ZIP package原创 2017-12-26 11:33:50 · 6445 阅读 · 0 评论 -
Python2.x与3.x版本区别
Python的3.0版本,常被称为Python 3000,或简称Py3k。相对于Python的早期版本,这是一个较大的升级。为了不带入过多的累赘,Python 3.0在设计的时候没有考虑向下相容。许多针对早期Python版本设计的程式都无法在Python 3.0上正常执行。为了照顾现有程式,Python 2.6作为一个过渡版本,基本使用了Python 2.x的语法和库,同时考虑了向Python转载 2017-12-06 11:02:00 · 361 阅读 · 0 评论 -
scripts(1-13) of 笨办法学Python
ex1.pyprint "Hello World!"print "Hello Again"print "I like typing this."print "This is fun."print 'Yay! Printing.'print "I'd much rather you 'not'."print 'I "said" do not touch this.'ex2.py# A co原创 2017-12-05 20:13:51 · 211 阅读 · 0 评论 -
Python学习笔记
1.pydoc raw_input python中pydoc模块可以从python代码中获取docstring,然后生成帮助信息。 pydoc用法简介2.argv 是所谓的“参数变量(argument variable)”,是一个非常标准的编程术语。在其他的编程语言里你 也可以看到它。这个变量包含了你传递给 Python 的参数。通过后面的练习你将对它有更多的了解。3.查一下 Zork 和 A原创 2017-12-04 17:58:17 · 292 阅读 · 0 评论