Lab1
-
git配置:今天学习之前,先把代码git上,按照这个以后每天都更新一下git^^
-
遇到问题:remote的时候我写错了网址,那就remote删除,再重新remote新的地址
``` git remote remove origin ```
-
-
print和return的引号
print(‘Hello World!’) 输出无引号,引号只是print写法 return ‘Exiting this function.’ return内容包括引号 -
python的与或非 and or not() Python 值为FALSE情况:
① 0 ② None ③'' (the empty string) ④ [] (the empty list) >>>True and 13 竟然为13 (A and B,A是True的话,结果就是B) >>>1 and 2 and 3 and 4 结果为4,1是True就由后面决定,以此类推 **python只要提前知道结果,就不会继续判断了**
-
error信息,debug能力很重要,看得懂报错信息
| Error Types | Descriptions |
| -------- | ----- |
| SyntaxError 语法错误 | Contained improper syntax (如少了冒号,括号,引号)
|
| IndentationError 缩进错误 | Contained improper indentation (python缩进很严格) |
| TypeError 类型错误 | Attempted operation on incompatible types (如不同类型无法相加) 或者调用函数时参数不正确 |
|ZeroDivisionError |Attempted division by zero除零| -
python bool(-1)是TRUE,一直以为是fasle,所有非零都为真,cpp也是如此
-
人家写的比我简洁
total, stop = 1, n-k
while n > stop:
total, n = total*n, n-1
return total
- python3 -m doctest “filename” 真的很好用