小编unh*_*ler的帖子

IEnumerator的目的是什么?

大家好我搜索IEnumerator但无法理解它.如果有人帮助我,这将是很大的帮助.

基本上试图了解它在这段代码中的作用

string requestUriString = URL;
if (requestUriString.IndexOf("http://", StringComparison.InvariantCultureIgnoreCase) < 0)
{
    requestUriString = "http://" + requestUriString;
}
WebRequest request = WebRequest.Create(requestUriString);
try
{
    IEnumerator enumerator;
    StreamReader reader = new StreamReader(request.GetResponse().GetResponseStream(), Encoding.UTF8);
    string sSourceString = reader.ReadToEnd();
    reader.Close();
    string str6 = this.funcParseStringFromString2String(sSourceString, "<div class=\"title\">", "<div class=\"searches_related\">", false);
    ArrayList list = new ArrayList();
    list = this.funcParseStringFromString2Stringx(str6, "<h3><a ", "</h3>", false);
    int num = this.DataGridView2.RowCount + 1;
    try
    {
        enumerator = list.GetEnumerator();
        while (enumerator.MoveNext())
        {
            string str8 = Conversions.ToString(enumerator.Current);
            string str7 = this.funcParseStringFromString2String(str8, …
Run Code Online (Sandbox Code Playgroud)

c#

0
推荐指数
1
解决办法
2961
查看次数

python异常:如何打印嵌套try的所有调试信息?

我有代码:

try:
    print test.qwerq]
    try:
        print test.sdqwe]
    except:
        pass
except:
   pass
Run Code Online (Sandbox Code Playgroud)

如何在嵌套try中打印所有错误的调试信息?

python

0
推荐指数
1
解决办法
613
查看次数

当方法在jUnit中抛出异常时

对于在jUnit测试中抛出异常的方法,您如何处理?如您所见,该类中的addAnswer方法Question可能会抛出异常.在shouldFailifTwoAnswerAreCorrect方法中,我想检查是否抛出了异常,但是在shouldAddAnswersToQuestion

我应该MultipleAnswersAreCorrectException从私有addAnswerToQuestion方法中添加throws 并尝试/ catch shouldAddAnswersToQuestion或者在该方法中抛出它吗?

当方法在测试中抛出异常时,你会怎么做?

public class QuestionTest {

    private Question question;

    @Before
    public void setUp() throws Exception {
        question = new Question("How many wheels are there on a car?", "car.png");
    }

    @Test
    public void shouldAddAnswersToQuestion() {

        addAnswerToQuestion(new Answer("It is 3", false));
        addAnswerToQuestion(new Answer("It is 4", true));
        addAnswerToQuestion(new Answer("It is 5", false));
        addAnswerToQuestion(new Answer("It is 6", false));

        assertEquals(4, question.getAnswers().size());
    }

    @Test(expected = MultipleAnswersAreCorrectException.class)
    public void shouldFailIfTwoAnswersAreCorrect() { …
Run Code Online (Sandbox Code Playgroud)

java junit exception java-ee

0
推荐指数
1
解决办法
2294
查看次数

在类中使用"self"时是否有NameError?

我有以下Python(3.2)代码:

from pygame import *

class Application:

    def __init__(self):
        self.running = True
        self.display_surface = None
        self.size = self.width, self.height = 640, 480

        self.old_ticks = pygame.time.get_ticks
        self.new_ticks = None

        pygame.init()
            self.display_surface = pygame.display.set_mode(self.size, pygame.HWSURFACE | pygame.DOUBLEBUF)

    def on_event(self, event):
        if event.type == pygame.QUIT:
            self.running = False

    def on_loop(self):
        pass

    def on_render(self):
        pass

    def on_cleanup(self):
        pygame.quit()

    def regulate_time(self):
        self.new_ticks = pygame.time.get_ticks

        while (self.new_ticks < self.old_ticks + 1000):
            pass

        self.old_ticks = self.new_ticks

    def load_images(self):
        pass

    while(self.running == True):
        for event in pygame.event.get():
            self.on_event(event) …
Run Code Online (Sandbox Code Playgroud)

python pygame

0
推荐指数
1
解决办法
156
查看次数

模拟列表的Mockito问题

我想模拟一个列表

private Item populateData(Item i) {
    List<Person> groupIdList = xyzDao.getData(id);
    for (Person p: groupIdList) {

    }
}
Run Code Online (Sandbox Code Playgroud)

我想通过模拟groupIdList来测试函数如何执行此操作?

java mockito

0
推荐指数
1
解决办法
6567
查看次数

如何将脚本转换为函数

我有一个我之前写过的脚本,现在正在尝试创建一个主页来运行这个脚本和其他脚本.我知道我必须把它变成一个函数然后在nesicary时调用它但我在函数部分遇到了一些麻烦.非常感谢任何帮助和建议.下面是我引用的脚本.

#A Python math script
a = float(raw_input("Enter the first number: "))
b = float(raw_input("Enter the second number: "))

print "Your answer is: ",(a*b)
Run Code Online (Sandbox Code Playgroud)

python

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

标签 统计

python ×3

java ×2

c# ×1

exception ×1

java-ee ×1

junit ×1

mockito ×1

pygame ×1