亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

隨便輸入范圍內的數字,結果報錯說if not num_input.isdight():?

隨便輸入范圍內的數字,結果報錯說if not num_input.isdight():?

慕少森 2022-05-06 11:07:11
#!/usr/bin/env python#coding:UTF-8import randomnumber = random.randint(1,101)guess=0while True:num_input =input("please input one integer that is 1 to 100:")guess += 1if not num_input.isdight():print("please input interger")elif int(num_input) < 0 or int(num_input) >= 100:print("the number should be in 1 to 100")else:if number==int(num_input):print("you are right")breakelif number > int(num_input):print("your number is more less")elif number < int(num_input):print("your number is more bigger")else:print("I will not work")我運行隨便輸入范圍內的數字 結果報錯說if not num_input.isdight():AttributeError: 'str' object has no attribute 'isdight' 怎么回事 謝謝了
查看完整描述

1 回答

?
慕絲7291255

TA貢獻1859條經驗 獲得超6個贊


#!/usr/bin/env python#coding:UTF-8  import randomnumber=random.randint(1,101)guess=0while True:      num_input=raw_input("please input one integer that is 1 to 100:")    guess+=1      if not num_input.isdigit():#是isdigit        print("please input interger")    elif int(num_input)< 0 or int(num_input)>= 100:        print("the number should be in 1 to 100")    else:        if number==int(num_input):            print("you are right")            break        elif number>int(num_input):            print("your number is more less")        elif number<int(num_input):            print("your number is more bigger")        else:                     print("I will not work")



查看完整回答
反對 回復 2022-05-10
  • 1 回答
  • 0 關注
  • 157 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號