1.技术交流QQ群【JAVA,.NET,BigData,AI】:170933152

我们在运行python脚本时遇到错误报错 IndentationError: unexpected indent。 
如下图:

>>>      with tf.variable_scope("",reuse=True):File "<stdin>", line 1with tf.variable_scope("",reuse=True):^
IndentationError: unexpected indent

原因

字母意思就是不希望有缩进,去掉空格和tab。 
看看我们的代码如下: 
 
发现第一行没有顶格写,python 对代码的格式要求很严格,python没有分号,用严格的缩进表示上下级从属层级关系,第一行需要顶格写,然后根据冒号:后续的代码行需要有缩进,并且有层级。

解决方式

把报错行多余的缩进删除即可。 
符合代码的格式要求:第一行需要定格写,然后根据冒号:之后的代码行需要有缩进,并且有层级,第二个冒号后面的代码不能超过第一个冒号后面的代码。同样的缩进表示同一个层级。

2.IndentationError: expected an indented block

>>> import tensorflow as tf
>>> g1 = tf.Graph()
>>> with g1.as_default

TensorFlow工作笔记003---python异常大全IndentationError: unexpected indent_expected indented block相关推荐

  1. Python异常:IndentationError: unexpected unindent

    Python异常:IndentationError: unexpected unindent 异常分析:缩进问题,Python是按空格进行分割代码块的 解决办法:按提示在给出错误的行数附近查看,是否缩 ...

  2. python问题:IndentationError:expected an indented block错误解决

    原文地址  http://blog.csdn.net/neilhappy/article/details/7724959 Python语言是一款对缩进非常敏感的语言,给很多初学者带来了困惑,即便是很有 ...

  3. Python报错“IndentationError: expected an indented block“

    问题描述: 一段python代码中使用了if name == 'main':,运行程序是报错"IndentationError: expected an indented block&quo ...

  4. python 报错:IndentationError: expected an indented block

    def get_formatted_name_0(first_name,last_name,middle_name=''):"""返回整洁的姓名""& ...

  5. python错误:IndentationError: expected an indented block,教你一招搞定

    大家这个问题一般只出现与新手,大家都知道python一般都是靠缩进来区分,C语言都是用括号,每种语言都是不一样的,下面以一个最简单的代码来展示一下这种问题解决办法: 问题展示 问题:显示在代码第6行遇 ...

  6. python 报错 IndentationError: expected an indented block SyntaxError: invalid character in identifie

    红色方框那里敲击一个空格就好! 输入要在全英情况下! 另外,还要注意括号的事情.括号别出错误! IndentationError: expected an indented block的报错: Syn ...

  7. 成功解决python中出现的IndentationError: expected an indented block的错误

    成功解决python中出现的IndentationError: expected an indented block的错误 目录 解决问题 解决思路 解决方法 解决问题 当在python中出现这个错误 ...

  8. Python报错:IndentationError: expected an indented block

    IndentationError: expected an indented block 直译为:缩进错误:需要缩进的块 在Python中,函数间的判定归属由缩进的块来决定而不是一组组括号 出现这个错 ...

  9. python问题:IndentationError:expected an indented blo

    2019独角兽企业重金招聘Python工程师标准>>> Python语言是一款对缩进非常敏感的语言,给很多初学者带来了困惑,即便是很有经验的Python程序员,也可能陷入陷阱当中.最 ...

最新文章

  1. matlab的基础使用
  2. C/C++编译预处理指令
  3. latex中report目录_LaTeX目录格式控制
  4. 探索性数据分析EDA及数据分析图表的选择
  5. C++学习之路 | PTA乙级—— 1070 结绳 (25 分)(精简)
  6. 自定义behavior-仿华为应用市场
  7. python123第七周小测验_python+request+untitest的接口自动化测试
  8. 使用facebook账号登录
  9. Java设置时间为0时0分0秒和23时59分59秒
  10. Java8 jdk1.8新特性
  11. JavaSE + bluecove 蓝牙连接
  12. 最全的大数据学习资料整理
  13. DB2根据指定列筛选重复数据
  14. 大数据时代从繁乱冗杂中精准提取核心文本信息 × Python Tkinter 生成词云图
  15. mysql acid
  16. 设计模式 | 为什么要学设计模式?懂兵法才能当好将军
  17. 【多线程】优雅使用线程池结合CompletableFuture实现异步编排
  18. FileReader FileInputStream InputStreamReader BufferedReader 作用与区别
  19. m基于MATLAB-GUI的GPS数据经纬度高度解析与kalman分析软件设计
  20. 微信小程序之model弹框

热门文章

  1. python:filter用法
  2. QT 多线程程序设计 -互斥
  3. 【转】QT中窗口刷新事件的学习总结
  4. 你不知道的Event Loop
  5. 怎么样做好手机网站的优化和推广呢?
  6. 数据库操作:MFC连接与MYSQL
  7. iBeacon的第一篇(基于Swift实现)
  8. mysql/mariadb主从复制
  9. Bootstrap基础二 网格系统
  10. 不插网线 开机速度加快