Skip to main content
 首页 » 编程设计

python之在 Python 中将字符串更改为 int

2025年05月04日17myhome

<分区>

我是 python 新手。我正在尝试制作一个小型电梯程序。

代码:

import time 
elavator = True 
# 0 is B floor // basement 
elavatorFloors = [0,1,2,3,4,5] 
 
while elavator == True: 
    getLevel = input ("Which floor would you like to visit? ( 1 - 5) ") 
    time.sleep(2) 
    print "you're now at floor, " +int.getLevel 

我得到这个错误:AttributeError: type object 'int' has no attribute 'getLevel' 除了将 str 更改为 int 之外,我是否使用了任何糟糕的技术?很想提高自己的编程思维和代码编写能力。谢谢:)