TypeError 'str'객체는 호출 할 수 없습니다-Python

Bkrause404

저는 Python을 처음 접했고 기본적으로 알람 시계로 작동하는 프로그램을 작성하려고합니다. 사용자에게 알람을 설정할 특정 시간을 묻는 메시지를 표시 한 다음 해당 시간이 발생하면 txt 파일의 YouTube 동영상 목록에서 가져온 YouTube 동영상이 재생됩니다. 그러나 여전히 파이썬 구문에 익숙하지 않기 때문에 왜이 오류가 발생하는지 잘 모르겠습니다. 내 코드는 다음과 같습니다.

import time

def addVideo():
    videoToAdd = raw_input("Enter the url of the video to add: ")
    with open('alarmVideos.txt', 'w') as f:
        f.write(videoToAdd + '\n')

alarmTime = raw_input("When would you like to set your alarm to?: \nPlease use this format: 01:00\n")

localTime = time.strftime("%H:%M") 

addVideo = raw_input("Would you like to add a video to your list? (y/n): \n")

if addVideo == 'y' or addVideo == 'n':
    addVideo()


print "Your alarm is set to:", alarmTime

이 오류가 발생합니다.

Traceback (most recent call last):
  File "C:\Users\bkrause080\Desktop\Free Time Projects\LearningPythonProjects\alarmClock.py", line 15, in <module>
    addVideo()
TypeError: 'str' object is not callable

도움이된다면 사용자가 비디오를 목록에 추가 할 것인지 여부에 대해 y / n을 입력 한 후이 오류가 발생합니다. 도움을 주셔서 감사합니다!

알 수 없는

문제는 함수 이름과 변수를 같은 이름 (addVideo)으로 명명했기 때문에 Python이 함수와 변수를 '혼동'합니다.

import time

def addVideo():
    videoToAdd = raw_input("Enter the url of the video to add: ")
    with open('alarmVideos.txt', 'w') as f:
        f.write(videoToAdd + '\n')

alarmTime =raw_input("When would you like to set your alarm to?: \nPlease use this format: 01:00\n")

localTime = time.strftime("%H:%M")

add_Video = raw_input("Would you like to add a video to your list? (y/n): \n")

if add_Video == 'y' or add_Video == 'n':
    addVideo()


print( "Your alarm is set to:", alarmTime)

산출:

When would you like to set your alarm to?: 
Please use this format: 01:00

Would you like to add a video to your list? (y/n): 
n
Enter the url of the video to add: grg
Your alarm is set to: 

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

Python / Pygame TypeError : 'str'객체는 호출 할 수 없습니다.

분류에서Dev

Python 3.4 : TypeError : 'str'객체는 호출 할 수 없습니다.

분류에서Dev

TypeError : 'str'객체는 호출 할 수 없습니다-Python

분류에서Dev

Python str () : TypeError : 'str'객체를 호출 할 수 없습니다-중지 코드

분류에서Dev

TypeError : 'float'객체는 Python에서 호출 할 수 없습니다.

분류에서Dev

TypeError : 'int'객체는 Python 3을 호출 할 수 없습니다.

분류에서Dev

TypeError : 'int'객체는 Python으로 호출 할 수 없습니다.

분류에서Dev

Python Tkinter TypeError : 'int'객체는 호출 할 수 없습니다.

분류에서Dev

TypeError : 'str'객체는 Python을 통해 Selenium을 사용하여 호출 할 수 없습니다.

분류에서Dev

TypeError : 'str'객체는 Python을 통해 Selenium을 사용하여 호출 할 수 없습니다.

분류에서Dev

TypeError : 'str'개체는 MySQL에서 호출 할 수 없습니다.

분류에서Dev

django-selenium TypeError : 'str'개체를 호출 할 수 없습니다.

분류에서Dev

TypeError : 'dict'객체는 python3을 호출 할 수 없습니다.

분류에서Dev

TypeError : '모듈'객체는 Python3을 호출 할 수 없습니다.

분류에서Dev

TypeError : '모듈'객체는 Spacy Python에서 호출 할 수 없습니다.

분류에서Dev

TypeError : print를 호출 할 때 'str'개체를 호출 할 수 없습니다.

분류에서Dev

TypeError : 'str'객체는 while 루프 내에서 사전을 인쇄하기 위해 호출 할 수 없습니다.

분류에서Dev

TypeError 'bool'객체는 django에서 호출 할 수 없습니다.

분류에서Dev

TypeError : 'int'객체는 호출 할 수 없습니다 .``, len ()

분류에서Dev

for 루프 내에서 열린 상태에서 TypeError : 'str'개체를 호출 할 수 없습니다 (Python).

분류에서Dev

TypeError : 파일을 읽을 때 'str'개체를 호출 할 수 없습니다.

분류에서Dev

Python Script TypeError : 'int'개체를 호출 할 수 없습니다.

분류에서Dev

Python 오류 : TypeError : 'list'개체를 호출 할 수 없습니다.

분류에서Dev

Python / Pygame : TypeError : '모듈'개체를 호출 할 수 없습니다.

분류에서Dev

Python-TypeError : 'list'개체를 호출 할 수 없습니다.

분류에서Dev

Python TypeError : '모듈'개체를 호출 할 수 없습니다.

분류에서Dev

Python setter TypeError : 'int'개체를 호출 할 수 없습니다.

분류에서Dev

Python 3 [TypeError : 'str'객체는 소켓으로 작업 할 때 정수로 해석 할 수 없습니다.]

분류에서Dev

TypeError : 'Connection'객체는 mysqldb를 사용하는 Python 스크립팅에서 호출 할 수 없습니다.

Related 관련 기사

  1. 1

    Python / Pygame TypeError : 'str'객체는 호출 할 수 없습니다.

  2. 2

    Python 3.4 : TypeError : 'str'객체는 호출 할 수 없습니다.

  3. 3

    TypeError : 'str'객체는 호출 할 수 없습니다-Python

  4. 4

    Python str () : TypeError : 'str'객체를 호출 할 수 없습니다-중지 코드

  5. 5

    TypeError : 'float'객체는 Python에서 호출 할 수 없습니다.

  6. 6

    TypeError : 'int'객체는 Python 3을 호출 할 수 없습니다.

  7. 7

    TypeError : 'int'객체는 Python으로 호출 할 수 없습니다.

  8. 8

    Python Tkinter TypeError : 'int'객체는 호출 할 수 없습니다.

  9. 9

    TypeError : 'str'객체는 Python을 통해 Selenium을 사용하여 호출 할 수 없습니다.

  10. 10

    TypeError : 'str'객체는 Python을 통해 Selenium을 사용하여 호출 할 수 없습니다.

  11. 11

    TypeError : 'str'개체는 MySQL에서 호출 할 수 없습니다.

  12. 12

    django-selenium TypeError : 'str'개체를 호출 할 수 없습니다.

  13. 13

    TypeError : 'dict'객체는 python3을 호출 할 수 없습니다.

  14. 14

    TypeError : '모듈'객체는 Python3을 호출 할 수 없습니다.

  15. 15

    TypeError : '모듈'객체는 Spacy Python에서 호출 할 수 없습니다.

  16. 16

    TypeError : print를 호출 할 때 'str'개체를 호출 할 수 없습니다.

  17. 17

    TypeError : 'str'객체는 while 루프 내에서 사전을 인쇄하기 위해 호출 할 수 없습니다.

  18. 18

    TypeError 'bool'객체는 django에서 호출 할 수 없습니다.

  19. 19

    TypeError : 'int'객체는 호출 할 수 없습니다 .``, len ()

  20. 20

    for 루프 내에서 열린 상태에서 TypeError : 'str'개체를 호출 할 수 없습니다 (Python).

  21. 21

    TypeError : 파일을 읽을 때 'str'개체를 호출 할 수 없습니다.

  22. 22

    Python Script TypeError : 'int'개체를 호출 할 수 없습니다.

  23. 23

    Python 오류 : TypeError : 'list'개체를 호출 할 수 없습니다.

  24. 24

    Python / Pygame : TypeError : '모듈'개체를 호출 할 수 없습니다.

  25. 25

    Python-TypeError : 'list'개체를 호출 할 수 없습니다.

  26. 26

    Python TypeError : '모듈'개체를 호출 할 수 없습니다.

  27. 27

    Python setter TypeError : 'int'개체를 호출 할 수 없습니다.

  28. 28

    Python 3 [TypeError : 'str'객체는 소켓으로 작업 할 때 정수로 해석 할 수 없습니다.]

  29. 29

    TypeError : 'Connection'객체는 mysqldb를 사용하는 Python 스크립팅에서 호출 할 수 없습니다.

뜨겁다태그

보관