首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >TypeError:无法使用input()调用“str”对象

TypeError:无法使用input()调用“str”对象
EN

Stack Overflow用户
提问于 2019-05-14 03:19:32
回答 4查看 7.6K关注 0票数 2

我有以下代码,它应该询问用户2的文件名。我得到一个错误的输入()在第二个函数,但不是在第一个,我不明白…下面是错误:

output = getOutputFile()文件"splitRAW.py",第22行,in getOutputFile fileName = input("\t=> ") TypeError:'str‘对象不可调用

代码语言:javascript
复制
# Loops until an existing file has been found
def getInputFile():
    print("Which file do you want to split ?")
    fileName = input("\t=> ")
    while 1:
        try:
            file = open(fileName, "r")
            print("Existing file, let's continue !")
            return(fileName)
        except IOError:
            print("No such existing file...")
            print("Which file do you want to split ?")
            fileName = input("\t=> ")

# Gets an output file from user
def getOutputFile():
    print("What name for the output file ?")
    fileName = input("\t=> ")

下面是我的main():

代码语言:javascript
复制
if __name__ == "__main__":
    input = getInputFile()
    output = getOutputFile()
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56118639

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档