本问题在python 3x 中不会出现 ,

下面说下问题发生的原因

# -*- coding: utf-8 -*-
import sys
reload(sys)
sys.setdefaultencoding("utf-8")content = input("input message:")
print content

输入 数字问题 ,当输入字母或者文字的时候出现下面的问题

这个问题的处理方法有2中

1 输入字母或者文字的时候带上双引号 “” 或者单引号

感觉这个处理不是很好

所以建议使用方法2

把input 换成 raw_input

# -*- coding: utf-8 -*-
import sys
reload(sys)
sys.setdefaultencoding("utf-8")content = raw_input("input message:")
print content

python 3x 不支持 raw_input 不过python3 x 中不会出现,上面的问题

当然还有一种可能,就是你使用的python 2x 中使用input 而你输入的是字母或者问题,这一种情况,你需要把input 改为raw_input 或者 在你的工具把python 的版本修改 3x

python2x NameError: name ‘abc‘ is not defined相关推荐

  1. NameError: name xx is not defined

    这个问题有很多类型的,这里说下我遇到的这个类型 首先我是获取input 值之后提示NameError: name xx is not defined 最后发现是python 2x 与 python 3 ...

  2. Python报错:NameError: name ‘wraps‘ is not defined

    @wraps(func) NameError: name 'wraps' is not defined 解决方法: (1)安装functiontools:pip install functiontoo ...

  3. NameError: name 'go' is not defined

    最近在学习fbprophet时,按照安装步骤,搭建好环境之后,使用官方教程进行学习.在执行到下面这句时报错 fig = plot_plotly(m, forecast) # This returns ...

  4. Python 解决 :NameError: name ‘reload‘ is not defined 问题

    Python 解决 :NameError: name 'reload' is not defined 问题 参考文章: (1)Python 解决 :NameError: name 'reload' i ...

  5. 【错误记录】执行 Python 程序报错 ( NameError: name ‘reload‘ is not defined )

    文章目录 一.报错信息 二.解决方案 一.报错信息 在 Windows 的 cmd 命令行运行 python 脚本时 , 报如下错误 : 执行 python ApkTool.py -analyse - ...

  6. py+selenium 报错NameError: name 'NoSuchElementException' is not defined【已解决】

     报错:NameError: name 'NoSuchElementException' is not defined  如图 解决方法: 头部加一句:from selenium.common.exc ...

  7. 成功解决NameError: name ‘norm‘ is not defined

    成功解决NameError: name 'norm' is not defined 目录 解决问题 解决思路 解决方法 解决问题 NameError: name 'norm' is not defin ...

  8. 成功解决NameError: name 'file' is not defined

    成功解决NameError: name 'file' is not defined 目录 解决问题 解决思路 解决方法 解决问题 NameError: name 'file' is not defin ...

  9. 成功解决NameError: name 'apply' is not defined

    成功解决NameError: name 'apply' is not defined 目录 解决问题 解决思路 解决方法 解决问题 NameError: name 'apply' is not def ...

最新文章

  1. 算法工程师养成记(附精选面试题)
  2. Windows 10截屏动画失效怎么恢复?
  3. 网络推广外包浅析当下网站优化处于健康状态有利于网络推广外包
  4. POJ-3154-Graveyard
  5. CSS基础「一」基础选择器 / 字体属性 / 文本属性 / 三种样式表
  6. TensorFlow环境配置----Mac OS
  7. 计算机屏保的功能,电脑的屏保自动出来格言
  8. 全链路压测实施思路流程分析
  9. postman设置为中文
  10. 讲真,只有low逼才热衷于打脸
  11. u盘中毒文件为html文档,u盘中毒文件被隐藏了?教你如何快速恢复隐藏文件
  12. 人工智能新风口上,网易是否能够突围?
  13. 大白菜无法打开计算机硬盘,USB接口损坏了?教你windows7硬盘安装步骤图文详解!...
  14. 笔记|统计学习方法:感知机模型
  15. 计算机维护与维修方法,浅谈计算机维护与维修方法
  16. 雷哥爱财,取之有道:4个月取了4000块
  17. Java中获取日期和时间
  18. 我们已在路上,希望就在前方
  19. 图形学(1)概论及一些基础知识
  20. 数据结构:排序 思维导图

热门文章

  1. 补充cpusim图片
  2. 2022-2028年中国金融安防行业深度调研及投资前景预测报告
  3. SQL与NoSQL的区别 以MySQL与MongoDB为例
  4. c语言使用指定字符串替换特定的子串
  5. Python中正则表达式用法 重点格式以这个为准_首看_各种问题
  6. tensorflow兼容处理 tensorflow.compat.v1 tf.contrib
  7. tf.variance_scaling_initializer() tensorflow学习:参数初始化
  8. LeetCode中等题之特殊等价字符串组
  9. camera中LENS和SENSOR的CRA是如何搭配的?
  10. 目标形体形状轮廓重建:ICCV2019论文解析