鱼C论坛

 找回密码
 立即注册
查看: 1480|回复: 3

[已解决]小白求助

[复制链接]
发表于 2018-1-25 18:09:38 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
print('----------一个xiao游戏--------')
A = input('输入数字:')
#B = int(A)
if 0 < A < 88:
    print('你妹好漂亮@')
else:
    print('你大爷好丑')

为什么一定要加个变量B,转成int型
最佳答案
2018-1-25 18:11:34
本帖最后由 sky 于 2018-1-25 18:13 编辑

input返回的都是str

  1. >>> help(input)
  2. Help on built-in function input in module builtins:

  3. input(prompt=None, /)
  4.     Read a string from standard input.  The trailing newline is stripped.

  5.     The prompt string, if given, is printed to standard output without a
  6.     trailing newline before reading input.

  7.     If the user hits EOF (*nix: Ctrl-D, Windows: Ctrl-Z+Return), raise EOFError.
  8.     On *nix systems, readline is used if available.

  9. >>>
复制代码

Read a string
就是读取标准输入的字符串
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2018-1-25 18:11:34 | 显示全部楼层    本楼为最佳答案   
本帖最后由 sky 于 2018-1-25 18:13 编辑

input返回的都是str

  1. >>> help(input)
  2. Help on built-in function input in module builtins:

  3. input(prompt=None, /)
  4.     Read a string from standard input.  The trailing newline is stripped.

  5.     The prompt string, if given, is printed to standard output without a
  6.     trailing newline before reading input.

  7.     If the user hits EOF (*nix: Ctrl-D, Windows: Ctrl-Z+Return), raise EOFError.
  8.     On *nix systems, readline is used if available.

  9. >>>
复制代码

Read a string
就是读取标准输入的字符串
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2018-1-25 18:16:04 | 显示全部楼层
sky 发表于 2018-1-25 18:11
input返回的都是str

就是说input的是字符串,所以要input的改成数字,才能比较大小
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2018-1-25 18:18:00 | 显示全部楼层
小Gui 发表于 2018-1-25 18:16
就是说input的是字符串,所以要input的改成数字,才能比较大小

对的
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2026-3-6 09:36

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表