Python中文
首页
教程
问答
标签
搜索
登录
注册
“str”对象在python中不可调用
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>我在<code>password()</code>函数中调用这个函数<code>password()</code>,希望它能重新开始。然后出现“str”对象错误。在</p> <p>代码:</p> <pre><code>import time def sleepFor(sleepForInt): time.sleep(sleepForInt / 1000) def newScreen(): # adte it says for itemNew in range(26): print("\n") def logo(): # ^~- newScreen() print("\t\t\t\tLeigh Studio") indent(6) return None def indent(space): # adte it says for item in range(space): print("\n") def password(): userName = input("Enter registered UserName > ") user = userName indent(1) if userName == "leigh flix": confirm = input("Confirm UserName (y/n) > ") indent(2) if confirm == "y": password = input("\tenter password ) ") if password == "comics123": menu() else: print("Password is Incorrect") sleepFor(2000) password() else: password() else: print("No registered UserName as: " + user) sleepFor(2000) password() def printID(): print("C:/users/" + user) def menu(): response = input(printID()) while response != "quit": if response == "time": time.ctime() def main(): # main method logo() sleepFor(1200) newScreen() password() # ___Runs program___ main() </code></pre> <p>错误: <img src="https://i.stack.imgur.com/1gAjx.jpg" alt="enter image description here"/></p> <p>我不知道还有什么。哦,顺便说一句,这不是一个编译错误,而是一个运行时错误,如果我没有输入正确的密码(它是'comics123')。在</p> <p>我要问的问题是,有没有一种不同的方法来调用<code>password()</code> 函数,它不会得到这个错误,或者一种重复询问用户密码是否错误的方法。提前谢谢。在</p>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>你的问题在于:</p> <pre><code>password = input("\tenter password ) ") </code></pre> <p>在这个范围内的<code>password</code>这行后面是这个字符串变量,而不是函数。只需将此变量重命名为其他变量即可解决此问题。</p>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
我想从用户inpu创建一个类的实例
5 回答
我想从用户导入值,为此
5 回答
我想从用户那里得到一个整数输入,然后让for循环遍历该数字,然后调用一个函数多次
7 回答
我想从用户那里收到一个列表,并在其中执行一些步骤,然后在步骤完成后将其打印回来,但它没有按照我想要的方式工作
6 回答
我想从用户那里获取输入,并将值传递给(average=dict[x]/6),然后在那里获取resu
8 回答
我想从第一个列表中展示第一个词,然后从第二个列表中展示十个词,以此类推- Python
1 回答
我想从第一个空lin开始解析文本文件
6 回答
我想从简历、简历中提取特定部分
6 回答
我想从给定字典(python)的字符串中删除\u00a9、\u201d和类似的字符。
2 回答
我想从给定的网站Lin下载许多文件扩展名相同的Wget或Python文件
9 回答
我想从网上搜集一些关于抵押贷款的数据
6 回答
我想从网站上删除电子邮件地址
8 回答
我想从网站上读取数据该网站包含可下载的文件,然后我想用python脚本把它发送给oracle如何?
7 回答
我想从网站中提取数据,然后将其显示在我的网页上
5 回答
我想从网页上提取统计数据。
7 回答
我想从网页上解析首都城市,并在用户输入国家时在终端上打印它们
5 回答
我想从色彩图中删除前n个颜色,而不丢失原始颜色数
7 回答
我想从课堂上打印字典里的键
7 回答
我想从费用表中获取学生上次支付的费用,其中学生id=id
4 回答
我想从较低的顺序对多重列表进行排序,但我无法在一行中生成结果
6 回答