2013-11-21 3 views
1

내가 파이썬 프로그램을 작성하고이 없으며이 오류 얻을 :속성 오류 : 'INT'개체가 어떤 속성 '선택'

: 여기
Traceback (most recent call last): 
File "C:\Users\Joe\SkyDrive\Documents\Python Project\Python\Forest path.py", line 28, in <module> 
random = random.choice(accuracy) 
AttributeError: 'int' object has no attribute 'choice' 

코드의 비트가 참조됩니다됩니다
while health_1 > 0 and health > 0 and stamina > 0: 
    random = random.choice(accuracy) 
    if random != "0": 
     print("\n\n", random) 
     print("\nYou manage to hit the creature for", dmg, "damage!") 
     health_1 -= dmg 
     stamina -= stam_loss 
     print("The creature now has", health_1, "health") 
     print("\nThe creature hits you for 1 damage!") 
     health -= 1 
     print("Health:", health, "Stamina:", stamina,) 

랜덤 모듈을 한 번 실행 한 다음 오류를 생성합니다. 도움을 주시면 감사하겠습니다.

답변

3
random = random.choice(accuracy) 

당신은 첫 번째 반복의 int 값을 가져오고 모듈의 이름입니다 random,에 저장된다. 이제 random 변수는 random 모듈을 음영 처리합니다. 가장 좋은 해결 방법은 random 대신 다른 변수 이름을 사용하는 것입니다.