我有一个名为的文件tester.py,位于/project.
/project有一个名为的子目录lib,其文件名为BoxTime.py:
/project/tester.py
/project/lib/BoxTime.py
Run Code Online (Sandbox Code Playgroud)
我想导入BoxTime的tester.我试过这个:
import lib.BoxTime
Run Code Online (Sandbox Code Playgroud)
结果如下:
Traceback (most recent call last):
File "./tester.py", line 3, in <module>
import lib.BoxTime
ImportError: No module named lib.BoxTime
Run Code Online (Sandbox Code Playgroud)
任何想法如何BoxTime从子目录导入?
编辑
该__init__.py是问题,但不要忘了提及BoxTime作为lib.BoxTime,或使用:
import lib.BoxTime as BT
...
BT.bt_function()
Run Code Online (Sandbox Code Playgroud) 使用TortoiseSVN,你如何标记代码?
分支的过程是否完全相同?
我知道你必须将代码复制到/ tag /文件夹,但是如何?
即我想将版本#复制到标签#.
它会影响/ trunk /吗?
我正打算Futures.awaitAll用可变数量的井来打电话Future.awaitAll被定义为awaitAll(timeout : Long, fts : Future[Any]*).我试过传入a List和a Array但两者都不起作用:
list = future1 :: future2 :: Nil
Futures.awaitAll(1000, list)
found : List[scala.actors.Future[Any]] required: scala.actors.Future[Any]
Run Code Online (Sandbox Code Playgroud)
编辑:我现在要做的是Futures.awaitAll使用可变数量的参数(1到n)以编程方式调用.所以使用Futures.awaitAll(1000, future1, future2)不是一种选择.
Scala编程的第8.8章没有给我任何提示如何解决这个问题,所以欢迎帮助:)
我想问一下,使用Google App Engine BulkLoader类导入数据需要使用哪种凭据
appcfg.py upload_data --config_file=models.py --filename=listcountries.csv --kind=CMSCountry --url=http://localhost:8178/remote_api vit/
Run Code Online (Sandbox Code Playgroud)
然后它要求我提供证书:
请输入localhost的登录凭据
这是一个models.py内容的提取,我使用这个listcountries.csv文件
class CMSCountry(db.Model):
sortorder = db.StringProperty()
name = db.StringProperty(required=True)
formalname = db.StringProperty()
type = db.StringProperty()
subtype = db.StringProperty()
sovereignt = db.StringProperty()
capital = db.StringProperty()
currencycode = db.StringProperty()
currencyname = db.StringProperty()
telephonecode = db.StringProperty()
lettercode = db.StringProperty()
lettercode2 = db.StringProperty()
number = db.StringProperty()
countrycode = db.StringProperty()
class CMSCountryLoader(bulkloader.Loader):
def __init__(self):
bulkloader.Loader.__init__(self, 'CMSCountry',
[('sortorder', str),
('name', str),
('formalname', str),
('type', str),
('subtype', str),
('sovereignt', str),
('capital', str), …Run Code Online (Sandbox Code Playgroud) 我有以下枚举 - >
public enum SyncStatus
{
Unavailable = 0,
Checking = 5,
StartedAspNetDb = 10,
FinishedAspNetDb = 20,
StartedMatrixDb = 30,
FinishedMatrixDb = 40,
StartedConnectDb = 50,
FinishedConnectDb = 60,
StartedCmoDb = 70,
FinishedCmoDb = 80,
StartedMcpDb = 90,
FinishedMcpDb = 100
}
Run Code Online (Sandbox Code Playgroud)
我在这里使用 - >
SyncInBackground.ReportProgress(SyncStatus.StartedAspNetDb);
MergeRepl aspnetdbMergeRepl = new MergeRepl(SystemInformation.ComputerName + "\\SQLEXPRESS", "WWCSTAGE", "aspnetdb", "aspnetdb", "aspnetdb");
aspnetdbMergeRepl.RunDataSync();
SyncInBackground.ReportProgress(SyncStatus.FinishedAspNetDb);
SyncInBackground.ReportProgress(SyncStatus.StartedMatrixDb);
MergeRepl matrixMergeRepl = new MergeRepl(SystemInformation.ComputerName + "\\SQLEXPRESS", "WWCSTAGE", "MATRIX", "MATRIX", "MATRIX");
matrixMergeRepl.RunDataSync();
SyncInBackground.ReportProgress(SyncStatus.FinishedMatrixDb);
SyncInBackground.ReportProgress(SyncStatus.StartedConnectDb);
MergeRepl connectMergeRepl = new …Run Code Online (Sandbox Code Playgroud) 我正在构建一个Java框架,它将监听事件,然后在Jython中处理它们.不同的事件类型将被发送到不同的脚本.
由于在调用PythonInterpreter.exec()时jython需要相当长的时间来编译脚本,因此我必须预编译脚本.我是按照以下方式做的:
// initialize the script as string (would load it from file in final version)
String script = "print 'foo'";
// get the compiled code object
PyCode compiled = org.python.core.__builtin__.compile( script, "<>", "exec" );
Run Code Online (Sandbox Code Playgroud)
PyCode编译对象将被推送到存储库并在事件进入时使用
PythonInterpreter pi = new PythonInterpreter();
pi.set( "variable_1", "value_1");
pi.set( "variable_x", "value_x");
pi.exec( compiled );
Run Code Online (Sandbox Code Playgroud)
现在,对于我的难题 - 可能会发生某些类型的多个事件同时发生 - 因此同时运行多个脚本实例.
几乎所有脚本都可能保持短暂 - 最多100行,没有循环.数字和频率是完全随机的(用户生成的事件),每个事件类型可以是每秒0到大约200.
最好的方法是什么?我正在寻找一些可能性:
2号和3号的组合可能是最好的 - 创建动态池大小?
那么,有什么想法吗?;)
我一直在考虑这个问题很长一段时间,我需要一种方法来添加对数据库中的注释的回复,但我不知道如何继续.
这是我目前的评论表(并没有多说但是它的开头):
CREATE TABLE IF NOT EXISTS `comments` (
`id` int(12) NOT NULL AUTO_INCREMENT,
`comment` text,
`user_id` int(12) DEFAULT NULL,
`topic_id` int(12) NOT NULL,
`ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `user_id` (`user_id`),
KEY `topic_id` (`topic_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=27 ;
Run Code Online (Sandbox Code Playgroud)
这是我当前的查询:
SELECT c.id, c.comment, c.user_id, u.username, u.photo
FROM (comments c)
JOIN users u ON c.user_id = u.id
WHERE c.topic_id = 9
Run Code Online (Sandbox Code Playgroud)
一种选择是创建一个名为"comment_replies"的新表,但我不确定如果我能够在一个查询中选择所有注释和注释回复,并且如果我添加一个名为"回复"的新列我就是不确定如何对它们进行排序以获得每个回复的每条评论.
我想知道如何处理这个问题.
编辑:
下面的答案是关于在1条评论和2条回复中添加parent_comment_id结果的这种数组:
array(2) {
[0]=>
object(stdClass)#17 (7) {
["id"]=>
string(2) "26"
["comment"]=> …Run Code Online (Sandbox Code Playgroud) 我试图通过iText合并1000个PDF文件.我不确定内存泄漏发生在哪里.下面是示例代码.请注意,我将合并到父文件后立即删除child-pdf文件.请指出以下代码中的错误,或者有没有更好的方法来做内存概念.这个过程是通过servlet完成的(不是独立的程序)
FileInputStream local_fis = null;
BufferedInputStream local_bis = null;
File localFileObj = null;
for(int taIdx=0;taIdx<totalSize;taIdx++){
frObj = (Form3AReportObject)reportRows.get(taIdx);
localfilename = companyId + "_" + frObj.empNumber + ".pdf";
local_fis = new FileInputStream(localfilename);
local_bis = new BufferedInputStream(local_fis);
pdfReader = new PdfReader(local_bis);
cb = pdfWriter.getDirectContent();
document.newPage();
page = pdfWriter.getImportedPage(pdfReader, 1);
cb.addTemplate(page, 0, 0);
local_bis.close();
local_fis.close();
localFileObj = new File(localfilename);
localFileObj.delete();
}
document.close();
Run Code Online (Sandbox Code Playgroud) 在C#中似乎有不少不同的列表.在我的头顶,我能够想出一对,但我相信还有更多.
List<String> Types = new List<String>();
ArrayList Types2 = new ArrayList();
LinkedList<String> Types4 = new LinkedList<String>();
Run Code Online (Sandbox Code Playgroud)
我的问题是,何时使用其中一个是有益的?
更具体地说,我从函数返回未知大小的列表,我想知道是否有一个更好的特定列表.