<legend id='HPnPl'><style id='HPnPl'><dir id='HPnPl'><q id='HPnPl'></q></dir></style></legend>
<tfoot id='HPnPl'></tfoot>
    1. <small id='HPnPl'></small><noframes id='HPnPl'>

      • <bdo id='HPnPl'></bdo><ul id='HPnPl'></ul>

      1. <i id='HPnPl'><tr id='HPnPl'><dt id='HPnPl'><q id='HPnPl'><span id='HPnPl'><b id='HPnPl'><form id='HPnPl'><ins id='HPnPl'></ins><ul id='HPnPl'></ul><sub id='HPnPl'></sub></form><legend id='HPnPl'></legend><bdo id='HPnPl'><pre id='HPnPl'><center id='HPnPl'></center></pre></bdo></b><th id='HPnPl'></th></span></q></dt></tr></i><div id='HPnPl'><tfoot id='HPnPl'></tfoot><dl id='HPnPl'><fieldset id='HPnPl'></fieldset></dl></div>
      2. 错误:'int' 对象不可下标 - Python

        时间:2023-08-04
        <tfoot id='5ozn1'></tfoot>
          <i id='5ozn1'><tr id='5ozn1'><dt id='5ozn1'><q id='5ozn1'><span id='5ozn1'><b id='5ozn1'><form id='5ozn1'><ins id='5ozn1'></ins><ul id='5ozn1'></ul><sub id='5ozn1'></sub></form><legend id='5ozn1'></legend><bdo id='5ozn1'><pre id='5ozn1'><center id='5ozn1'></center></pre></bdo></b><th id='5ozn1'></th></span></q></dt></tr></i><div id='5ozn1'><tfoot id='5ozn1'></tfoot><dl id='5ozn1'><fieldset id='5ozn1'></fieldset></dl></div>
              <tbody id='5ozn1'></tbody>
              <bdo id='5ozn1'></bdo><ul id='5ozn1'></ul>

              <small id='5ozn1'></small><noframes id='5ozn1'>

            • <legend id='5ozn1'><style id='5ozn1'><dir id='5ozn1'><q id='5ozn1'></q></dir></style></legend>

                  本文介绍了错误:'int' 对象不可下标 - Python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在尝试一段简单的代码,获取某人的姓名和年龄,并在他们 21 岁时告诉他/她...不考虑负面因素和所有这些,只是随机的.

                  I was trying a simple piece of code, get someone's name and age and let him/her know when they turn 21... not considering negatives and all that, just random.

                  我不断收到这个 'int' object is not subscriptable 错误.

                  I keep getting this 'int' object is not subscriptable error.

                  name1 = raw_input("What's your name? ")
                  age1 = raw_input ("how old are you? ")
                  x = 0
                  int([x[age1]])
                  twentyone = 21 - x
                  print "Hi, " + name1+ " you will be 21 in: " + twentyone + " years."
                  

                  推荐答案

                  问题出在行,

                  int([x[age1]])
                  

                  你想要的是

                  x = int(age1)
                  

                  您还需要将 int 转换为字符串以供输出...

                  You also need to convert the int to a string for the output...

                  print "Hi, " + name1+ " you will be 21 in: " + str(twentyone) + " years."
                  

                  完整的脚本看起来像,

                  name1 = raw_input("What's your name? ")
                  age1 = raw_input ("how old are you? ")
                  x = 0
                  x = int(age1)
                  twentyone = 21 - x
                  print "Hi, " + name1+ " you will be 21 in: " + str(twentyone) + " years."
                  

                  这篇关于错误:'int' 对象不可下标 - Python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:将 pandas 数据框列导入为字符串而不是 int 下一篇:Pandas 将 csv 读取为字符串类型

                  相关文章

                  最新文章

                  <i id='bLZG7'><tr id='bLZG7'><dt id='bLZG7'><q id='bLZG7'><span id='bLZG7'><b id='bLZG7'><form id='bLZG7'><ins id='bLZG7'></ins><ul id='bLZG7'></ul><sub id='bLZG7'></sub></form><legend id='bLZG7'></legend><bdo id='bLZG7'><pre id='bLZG7'><center id='bLZG7'></center></pre></bdo></b><th id='bLZG7'></th></span></q></dt></tr></i><div id='bLZG7'><tfoot id='bLZG7'></tfoot><dl id='bLZG7'><fieldset id='bLZG7'></fieldset></dl></div>
                  <tfoot id='bLZG7'></tfoot>
                    <legend id='bLZG7'><style id='bLZG7'><dir id='bLZG7'><q id='bLZG7'></q></dir></style></legend>
                      <bdo id='bLZG7'></bdo><ul id='bLZG7'></ul>

                    <small id='bLZG7'></small><noframes id='bLZG7'>