Python--错误总结1
来源:互联网 发布:欧洲人怎么看中国知乎 编辑:程序博客网 时间:2024/05/17 20:28
最近被安利了一本讲Python的书(《Python编程:从入门到实践》)#这大概就是悲剧的开端
首先,因为最早学的是C++还有C,所以并不是很注意缩进的问题(心情简单.jpg),然后,然后就没有然后了,(╯‵□′)╯︵┻━┻ (╯‵□′)╯︵┻━┻
好了,回归正题:
下面展示的代码来自↑上面提到的书第四章
#先展示正确代码
magicians = ['alice', 'david', 'carolina']for magician in magicians: print(magician.title() + ", that was a great trick!")
输出:
Alice, that was a great trick!
David, that was a great trick!
Carolina, that was a great trick!
#这个是第一个错误类型
magicians = ['alice', 'david', 'carolina']for magician in magicians: print(magician.title() + ", that was a great trick!")
File "/usercode/file.py", line 1
magicians = ['alice', 'david', 'carolina']
^
IndentationError: unexpected indent
在解释这个错误之前,我们先认识一个单词 逃)
- 朗文当代高级英语辞典
in‧dent 1
/ɪn'dent,ɪnˋdɛnt/ v. [T ]MEANINGS 义项
to start a line of writing further towards the middle of the page than other lines
〔书写时〕将〔行首〕缩格
•Use the Tab key to indent the first line of the paragraph. 用跳格键把该段的首行缩格。
in‧dent 2
/'ɪndent,ˋɪndɛnt/ n. [C ]MEANINGS 义项
- 1.
an official order for goods or equipment
〔正式的〕订(货)单
[+ for]
•He cancelled the indent for silk scarves. 他取消了真丝围巾的订单。
- 2.
an indentation
行首空格;凹口
- 21世纪大英汉词典
indent /in'dent; 'indent/
- vt.
- 1.
把(边缘等)刻成锯齿状:
to indent the edge of a wood board
把一块木板的边缘刻成锯齿状
- 2.
使凹进,使凹入:
The sea indents the coast.
海水将海岸冲击得凹凸不平。
- 展开更多3.
把(多份文件等)沿骑缝线割开(或撕开)(以备将来检验文件真伪)
- vi.
- 1.
形成锯齿状;形成凹口
- 2.
缩进排印,缩格书写
- 展开更多3.
签订合同
- n.
- 1.
锯齿形缺口;(V形)凹口
- 2.
1. (印刷中的)首行缩排;(书写中的)首行缩格
2. (缩排等时留出的)空格;缩格排印(或书写)的首行(或段落)
- 展开更多3.
师徒契约;定期服务合同
indent /in'dent; 'indent/
- vt.
- 1.
压凹痕于,压印于
- 2.
压印(图案等):
to indent patterns
压印图案
- n.
凹痕,凹坑
通过与正确代码的比较可以很容易发现其不同之处,即第一行开头处有一个空格(╯‵□′)╯︵┻━┻
原来学C++的时候完全没有遇到过,结果这里卡了两天,我还以为是编译器的问题,(╯‵□′)╯︵┻━┻
#接下来是第二个错误
magicians = ['alice', 'david', 'carolina']for magician in magicians:print(magician.title() + ", that was a great trick!")
File "/usercode/file.py", line 3
print(magician.title() + ", that was a great trick!")
^
IndentationError: expected an indented block
这里竟然又要求缩进了掀桌(Python,大概是在折磨我那弱小的心灵……)
- Python--错误总结1
- python —错误总结1
- python 错误类型总结
- PYTHON错误大总结!
- python学习错误总结
- python编译错误总结
- python脚本错误总结
- python 错误总结
- Python错误总结
- python错误总结
- python常见错误总结
- python 错误总结
- python常见错误总结结
- python使用中的错误总结
- Python错误和异常总结
- python-pytesseract安装错误总结
- python错误总结大全--(一)
- Python Pandas库 常见使用错误总结
- matlab dicom格式图像转为tif格式的读取
- http协议-request
- ResultSetMetaData
- 数组2·求最大值及其下标
- POJ-1050-To the Max-二维最大子序列和
- Python--错误总结1
- 从零开发B/S机架应用程序(五)
- 关于MatConvNet深度学习库Index exceeds matrix dimensions错误注意事项
- C++信息学奥赛一本通题库1034计算三角形面积
- 669. Trim a Binary Search Tree/110. Balanced Binary Tree/443. String Compression/266. Palindrome Per
- 2017.11.21 LeetCode
- 接口练习2
- orderfields
- JavaScript获取DOM元素的方法总结