Python
文章平均质量分 59
y912423222
这个作者很懒,什么都没留下…
展开
-
初学Python 之 报错 “ TypeError: 'str' object is not callable ”
TypeError: 'str' object is not callable 我的代码如下所示 class Restaurant(): '''描述餐馆的基本属性''' def __init__(self,restaurant_name,cuisine_type): self.restaurant_name = restaurant_name self.cuisine_type = c...原创 2018-07-13 13:20:09 · 2212 阅读 · 0 评论 -
python之单元测试--常见问题
原文 https://www.cnblogs.com/yin-tao/p/7041488.htmlPython在unittest.TestCase中提供了许多断言的方法。assertEqual(a,b) ---------> 核实a==bassertNotEqual(a,b) -----> 核实a!=bassertTrue(a) -------------> 核实...转载 2018-07-25 19:20:19 · 1103 阅读 · 0 评论 -
关于 Python错误 IndentationError: unexpected indent
都知道python是对格式要求很严格的,写了一些python但是也没发现他严格在哪里,今天遇到了IndentationError: unexpected indent错误我才知道他是多么的严格。 以后遇到了IndentationError: unexpected indent你就要知道python编译器是在告诉你“Hi,老兄,你的文件里格式不对了,可能是tab和空格没对齐的问题,你需要...转载 2018-07-26 11:03:08 · 191 阅读 · 0 评论 -
以下这段代码是在python中使用闭包时一段经典的错误代码
def foo(): a = 1 def bar(): a = a + 1 return a return bar这段程序的本意是要通过在每次调用闭包函数时都对变量a进行递增的操作。但在实际使用时>>> c = foo() >>> print c() Tracebac...转载 2018-10-26 11:17:49 · 417 阅读 · 0 评论 -
mac anaconda 指定路径虚拟环境 Django 安装
需要注意的问题1 一定要看 python的版本 和 django 的版本匹不匹配!! 特别是 在anaconda指定路径路径的时候,python版本号一定要标明 2 细心,细心,细心,下面不多说,上步骤1 创建一个项目目录,例如 :learning_log 2 在终端窗口创建虚拟环境 指定路径你要创建虚拟环境的路径conda create --prefix=...原创 2018-11-13 19:43:46 · 1410 阅读 · 0 评论