Python2与python3区别(二)
来源:互联网 发布:淘宝售后时间是多久 编辑:程序博客网 时间:2024/06/06 08:59
from pip._vendor.distlib.compat import raw_inputnum = 50guess = raw_input("please input :")if guess == num: print('equal')elif guess < num : print('lower')else: print('>')print ("Done!")
运行结果如下:Traceback (most recent call last): File "F:\JA\TestPython\guess.py", line 7, in <module> elif guess < num :TypeError: '<' not supported between instances of 'str' and 'int'原因:input()返回的数据类型是str,不能直接和整数进行比较,所以要用int()将str换成整数即可
第三行应该这样写:
guess = int(raw_input("please input :"))
阅读全文
0 0
- Python2与python3区别(二)
- python3 与 python2区别
- python2与python3区别(一)
- Python2与Python3的区别(二):raw_input与input
- Python2与Python3的区别
- python2 与 python3 语法区别
- python2 与 python3 语法区别
- python2与python3的区别
- python2与python3的区别
- Python3与Python2的区别
- python2 与 python3 语法区别
- python2 与 python3 语法区别
- python2 与 python3 语法区别
- python2 与 python3 语法区别
- python2与python3的区别
- python2与python3区别汇总
- Python2与Python3的区别
- python2 与 python3 语法区别
- 复选框选中
- Win10使用VMware虚拟机安装ubuntu
- app 功耗
- intellj maven package 报错 程序包不存在 找不到符号 解决办法
- 景中人
- Python2与python3区别(二)
- mariadb 下管理用户账号
- 一款以最新潮的方式来使用UIImage的swift插件
- 一款APP从设计稿到切图过程全方位揭秘(IOS版)
- 数据库中事务隔离级别
- Oracle merge into的用法,以及MySQL的相同功能语句
- 每日学习20170701--guava并发编制之Monitor使用
- linux命令eval的用法
- Javascript入门篇