小编Vin*_*Sai的帖子

要么重新中断此方法,要么重新抛出声纳中的“InterruptedException 问题”

在我的方法之一中,中断异常和执行异常即将到来。我像这样输入了 try catch 。

try{

  //my code
}catch(InterruptedException|ExecutionException e)

  Log.error(" logging it");
  throw new MonitoringException("it failed" , e)


//monitoringexception extends RunTimeException
Run Code Online (Sandbox Code Playgroud)

同样在我的方法中,我抛出了 InterruptedException,ExecutionException

我在声纳中遇到严重错误 - 重新中断此方法或重新抛出“ InterruptedException

有人知道怎么修这个东西吗。

请立即帮助。

java exception try-catch interrupted-exception throws

18
推荐指数
1
解决办法
2万
查看次数

在Python中使用main()调用参数是不好的做法

函数名是否应该main()为空并且在函数本身内调用参数,或者将它们作为函数的输入是否可接受main(arg1, arg2, arg3)

我知道它有效,但我想知道它是不是很糟糕的编程习惯.如果这是重复的道歉,但我看不出专门针对Python的问题.

python program-entry-point

6
推荐指数
2
解决办法
1457
查看次数

AttributeError:模块“importlib._bootstrap”没有属性“SourceFileLoader”

我是编程新手,所以我遇到了这个麻烦。我升级了我的 pip,然后使用 pip list、ipython Notebook、jupyter Notebook 来使用 anaconda,所以在所有这些命令之后我得到了一个答案:

Traceback (most recent call last):
  File "/home/bakhytgul/anaconda3/bin/pip", line 7, in <module>
    from pip._internal import main
  File "/home/bakhytgul/anaconda3/lib/python3.6/site-packages/pip/_internal/__init__.py", line 40, in <module>
    from pip._internal.cli.autocompletion import autocomplete
  File "/home/bakhytgul/anaconda3/lib/python3.6/site-packages/pip/_internal/cli/autocompletion.py", line 8, in <module>
    from pip._internal.cli.main_parser import create_main_parser
  File "/home/bakhytgul/anaconda3/lib/python3.6/site-packages/pip/_internal/cli/main_parser.py", line 12, in <module>
    from pip._internal.commands import (
  File "/home/bakhytgul/anaconda3/lib/python3.6/site-packages/pip/_internal/commands/__init__.py", line 6, in <module>
    from pip._internal.commands.completion import CompletionCommand
  File "/home/bakhytgul/anaconda3/lib/python3.6/site-packages/pip/_internal/commands/completion.py", line 6, in <module>
    from pip._internal.cli.base_command import Command
  File "/home/bakhytgul/anaconda3/lib/python3.6/site-packages/pip/_internal/cli/base_command.py", line 19, in <module>
    from …
Run Code Online (Sandbox Code Playgroud)

python django pip python-3.x

6
推荐指数
1
解决办法
3053
查看次数

定义变量

如果用户已经输入'tea''t'为自己的选择,我该如何定义变量beverage.lower()'tea'?因为

if beverage.lower()=='t'or beverage.lower()=='tea':
                beverage.lower()=='tea'
Run Code Online (Sandbox Code Playgroud)

line对整个程序本身绝对没有任何影响?

while True:
        beverage=raw_input("What is your preferred beverage: coffee, or tea?")
        if beverage.lower() not in ('coffee','tea','t','c'):
            if beverage.lower()=='t'or beverage.lower()=='tea':
                beverage.lower()=='tea'
            elif beverage.lower()=='c'or beverage.lower()=='coffee':
                beverage.lower()=='coffee'
            print("Sorry! I didn't quite catch that. Please try again! (Note that you can use the letter 'c' or the letter 't' to denote coffee or tea respectively!)")
            continue
        else:
            print("Ah! Fantastic choice!")
            break
Run Code Online (Sandbox Code Playgroud)

同样,我如何定义beverage.lower()作为另一个变量输入的用户?

python

2
推荐指数
1
解决办法
119
查看次数