TypeError: 'str' object is not callable (Python)

后端 未结 16 1110
忘了有多久
忘了有多久 2020-11-22 11:44

Code:

import urllib2 as u
import os as o
inn = \'dword.txt\'
w = open(inn)
z = w.readline()
b = w.readline()
c = w.readline()
x = w.readline         


        
16条回答
  •  有刺的猬
    2020-11-22 12:12

    This is the problem:

    global str
    
    str = str(mar)
    

    You are redefining what str() means. str is the built-in Python name of the string type, and you don't want to change it.

    Use a different name for the local variable, and remove the global statement.

提交回复
热议问题