pycharm中指出的错误帮助 [英] Help in error pointed out in pycharm

查看:396
本文介绍了pycharm中指出的错误帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

1。 Def displayMenu():pycharm说该函数应该是小写的。它对其他功能也是如此。

2.未解决 引用 'if__name __'  less ... (Ctrl + F1)

此检查检测到应该解决但不能解决的名称。由于动态调度和鸭子打字,这在有限但有用的情况下是可能的。顶级和类级别项目比实例项目支持更好。



此检查检测语句没有任何影响。



3.选择= int(输入输入选项(1 ... 4):)

语法错误:语法无效^



请帮我解决这个问题



我的尝试:



def displayMenu():

print()

print(1.读取客户档案)

print(2添加客户)

打印(3.搜索客户)

打印(4.结束)

打印( )



def readFile():

打印(读取文件代码)



if__name __ ==__ main__



选择= 0

而选择!= 4:

displayMenu()



Choice = int(输入输入选项(1 ... 4):)

NoOfAttempts = 1

while(选择< 1或Choice> 4)和NoOfAttempts< ; 3:

如果选择== 1:

readFile()

elif选择== 2:

打印(添加客户代码)

elif选择== 3:

打印(打印客户代码)

解决方案

你缺少一些括号。 input 是一个以字符串作为参数的函数。 int 是一个函数,它也接受一个字符串,在这种情况下是从输入调用的返回值。所以你需要



  输入选项(1 ... 4) - >提示字符串 
input(输入选项(1 ... 4)) - >输入函数调用使用字符串
int(输入(输入选择(1。 ..4))) - >使用输入结果调用int函数

Choice = int(输入( 输入选项(1 ... 4)))


1. Def displayMenu(): pycharm say that function should be in lowercase. Its says the same for the other function.
2. Unresolved reference 'if__name__' less... (Ctrl+F1)
This inspection detects names that should resolve but don't. Due to dynamic dispatch and duck typing, this is possible in a limited but useful number of cases. Top-level and class-level items are supported better than instance items.

This inspection detects statements without any effect.

3. Choice=int(input"Enter choice (1...4)":)
SyntaxError: invalid syntax ^

Please help me solve this problem

What I have tried:

def displayMenu():
print()
print("1. Read customer file")
print("2. Add customer")
print("3. Search for a customer")
print("4. End")
print()

def readFile():
print("Read file code")

if__name__=="__main__"

Choice= 0
while Choice !=4:
displayMenu()

Choice=int(input"Enter choice (1...4)":)
NoOfAttempts=1
while(Choice<1 or Choice>4) and NoOfAttempts<3:
if Choice==1:
readFile()
elif Choice==2:
print("Add customer code")
elif Choice==3:
print("Print customer code")

解决方案

You are missing a number of parentheses. input is a function which takes a string as its parameter. int is a function which also takes a string, in this case the return value from the call to input. So you need

#    "Enter choice (1...4)"             -> the prompt string
#    input("Enter choice (1...4)")      -> the input function call using the string
#    int(input("Enter choice (1...4)")) -> the int function call using the result of input
#
Choice=int(input("Enter choice (1...4)"))


这篇关于pycharm中指出的错误帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆