我必须在网络课程中编写一个类似选择性重复但需要一个计时器的程序.在谷歌搜索后我发现threading.Timer可以帮助我,我写了一个简单的程序只是为了测试如何threading.Timer工作是这样的:
import threading
def hello():
print "hello, world"
t = threading.Timer(10.0, hello)
t.start()
print "Hi"
i=10
i=i+20
print i
Run Code Online (Sandbox Code Playgroud)
这个程序运行正常.但是当我尝试以一种给出参数的方式定义hello函数时:
import threading
def hello(s):
print s
h="hello world"
t = threading.Timer(10.0, hello(h))
t.start()
print "Hi"
i=10
i=i+20
print i
Run Code Online (Sandbox Code Playgroud)
输出是:
hello world
Hi
30
Exception in thread Thread-1:
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/threading.py", line 522, in __bootstrap_inner
self.run()
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/threading.py", line 726, in run
self.function(*self.args, **self.kwargs)
TypeError: 'NoneType' object is not callable
Run Code Online (Sandbox Code Playgroud)
我不明白这是什么问题!谁能帮我?
我有样品"Hello,World!" 来自网络的代码,我想在我大学的服务器上的GPU上运行它.当我输入"gcc main.c"时,它会响应:
CL/cl.h:没有这样的文件或目录
我该怎么办?我怎么能有这个头文件?
我有python 2.6.1,因为它很旧我决定安装python 3.3.2但是,当我在我的mac中输入"python"它打印它是版本2.6.1并且当我输入python3时它显示这是3.3.2 .我安装了django 1.6但是当我检查时,了解它是为旧版本的python(python 2.6.1)安装的.我想为我的python 3.3.2安装它我该怎么办?任何卸载python 2.6.1的方法,当我在终端输入python时,它的版本是3.3.2吗?我有mac os 10.6.8
我有一个 Java 项目代码,其中一个类如下所示,但是当我想运行此代码时,我将在此类中遇到编译错误,其中一部分代码是:
package othello.view;
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import othello.ai.ReversiAI;
import othello.controller.AIControllerSinglePlay;
import othello.controller.AIList;
import othello.model.Board;
import othello.model.Listener;
@SuppressWarnings("serial")
public class TestFrameAIVSAI extends JFrame implements ActionListener, Logger,
Listener {
private static Border THIN_BORDER = new EmptyBorder(4, 4, 4, 4);
public JComboBox<Object> leftAICombo;
public JComboBox<Object> rightAICombo;
private JButton startTest;
private JButton pauseTest;
Run Code Online (Sandbox Code Playgroud)
错误来自两行public JComboBox<Object> leftAICombo;,public …
当我想在RI中加载Rsamtools包时,请看错误如下:
Error in get(method, envir = home) :
lazy-load database'/Library/Frameworks/R.framework/Versions/3.2/Resources/library/Rsamtools/ R/Rsamtools.rdb' is corrupt
In addition: Warning messages:
1: In .registerS3method(fin[i, 1], fin[i, 2], fin[i, 3], fin[i, 4], :
restarting interrupted promise evaluation
2: In get(method, envir = home) :
restarting interrupted promise evaluation
3: In get(method, envir = home) : internal error -3 in R_decompress1
Error: package or namespace load failed for ‘Rsamtools’
Run Code Online (Sandbox Code Playgroud)
sessionInfo的输出是:
R version 3.2.0 (2015-04-16)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.9 (Mavericks)
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 …Run Code Online (Sandbox Code Playgroud) 我是WPF的新手,我需要在一个元素中组合许多组件,并在窗口中为每个学生在数据库中添加该元素的新实例,例如每个学生2个文本块加1个文本框,我该怎么做?