使用setuptoolsPython,我可以在安装python项目时指定输出目录吗?
在我的项目目录中:
python setup.py install
我想将项目安装到/usr/share/myproject/目录中,例如.
我不想在命令行中指定输出目录.我想将此输出目录指定为setup.py.
本地时间返回 null。为什么?(我使用的是 Visual C++ 2008)
struct tm *tb;
time_t lDate;
time(&lDate);
tb = localtime(&lDate); // tb is null everytime I try this!
Run Code Online (Sandbox Code Playgroud) 假设我有一些存储在哈希中的新闻.我有不同的哈希值(每个哈希代表一个新闻):
news:1
news:2
news:3
...
Run Code Online (Sandbox Code Playgroud)
我想用KEYS命令检索所有键,如下所示:
KEYS news:*
Run Code Online (Sandbox Code Playgroud)
密钥未排序的问题:
news:3
news:1
news:2
Run Code Online (Sandbox Code Playgroud)
我想按正确的顺序检索密钥列表.我不确定哈希是否是我需要的结构.但是,根据redis文档:
Redis Hashes是字符串字段和字符串值之间的映射,因此它们是表示对象的完美数据类型(例如,具有多个字段的用户,如姓名,姓氏,年龄等):
将我的新闻对象存储在哈希中似乎是个好主意.
有什么建议 ?
假设我的页面中有一个简单的表单,如下所示:
<form action="/properties/search" method="GET" id="form_search">
<p>
<label for="price">Min price:</label>
<input type="text" name="min_price" id="min_price">
</p>
<p>
<label for="price">Max price:</label>
<input type="text" name="max_price" id="max_price">
</p>
<p>
<input type="submit">
</p>
</form>
Run Code Online (Sandbox Code Playgroud)
当我提交表单时,我有以下网址:
HTTP://.../properties/search MIN_PRICE = 100000&MAX_PRICE = 200000
我想更改此网址:
HTTP://.../properties/search价格= 100000,200000
为此,我使用JQuery和JQuery查询字符串插件:
$(document).ready(function() {
$("#form_search").submit(function() {
var querystring = rewrite_interval_qstring();
// querystring equals "?price=100000,200000" -> exactly what I want !
// ???
});
});
Run Code Online (Sandbox Code Playgroud)
如何更改(评论"???")提交网址?我已单独测试了以下说明,但它不起作用.
window.location = querystring;
window.location.href = querystring;
window.location.search = querystring;
Run Code Online (Sandbox Code Playgroud) 我在Javascript中编写了以下代码.
function main()
{
this.a ;
this.set = function()
{
a = 1;
}
}
var l = new main();
alert("Initial value of a is "+ l.a );
l.set();
alert("after calling set() value of a is "+ l.a );
Run Code Online (Sandbox Code Playgroud)
在这两种情况下,我得到a的值为未定义.为什么即使在我调用set()之后未定义?
我想在我的项目中使用自定义注释.
如何配置maven 3来处理我的注释.AbstractProcessor类的注释和实现嵌入在我的应用程序中.
我的注释仅适用于测试(src/test/java).
状态注释:
@Target(ElementType.METHOD)
public @interface State {
boolean success() default true;
}
Run Code Online (Sandbox Code Playgroud)
TestAnnotationsProcessor:
@SupportedAnnotationTypes("com.*****.client.State")
public class TestAnnotationsProcessor extends AbstractProcessor {
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
System.out.print("TESSST ANNOTATION");
return true;
}
}
Run Code Online (Sandbox Code Playgroud)
我不想把我的注释放在一个外部项目中......这将是愚蠢的,因为它真的取决于我的项目.
我怎样才能做到这一点 ?谢谢.
我想INNER JOIN在Zend2中的两个表之间做一个简单的操作.
具体来说,我想在Zend2中这样做:
SELECT * FROM foo, bar WHERE foo.foreign_id = bar.id;
我有一个FooTable:
class FooTable
{
protected $tableGateway;
public function __construct(TableGateway $tableGateway)
{
$this->tableGateway = $tableGateway;
}
public function get($id)
{
$rowset = $this->tableGateway->select(function (Select $select) {
$select->from('foo');
});
}
}
Run Code Online (Sandbox Code Playgroud)
将$select->from('foo');返回一个错误:
==> 由于此对象是在构造函数中使用表和/或模式创建的,因此它是只读的.
所以,我不能调整我的FROM语句来匹配FooTable和之间的简单内连接BarTable.
在 Python 中,我可以在整个类中声明属性。例如 :
class Foo:
def __init__(self):
self.a = 0
def foo(self):
self.b = 0
Run Code Online (Sandbox Code Playgroud)
当我有一个包含很多属性的大类时,很难检索我的类中的所有属性。
使用以下代码 (a) 还是下一个以下代码 (b) 更好:
a)在这里,很难找到所有属性:
class Foo:
def __init__(self):
foo_1()
foo_2()
def foo_1(self):
self.a = 0
self.b = 0
def foo_2(self):
self.c = 0
Run Code Online (Sandbox Code Playgroud)
b)在这里,很容易找到所有属性,但它漂亮吗?
class Foo:
def __init__(self):
(self.a, self.b) = foo_1()
self.c = foo_2()
def foo_1(self):
a = 0
b = 0
return (a, b)
def foo_2(self):
c = 0
return c
Run Code Online (Sandbox Code Playgroud)
简而言之,在类中声明属性的约定是什么?
编辑:
当然,这是一个简单的例子,这里不需要改进我的代码。想象一下一个复杂的类,它有很多在_init_ () 中调用的“小方法”(用来分割我的代码,提高可读性)。
我有这样一个快速路线:
app.get('/', auth.authOrDie, function(req, res) {
res.send();
});
Run Code Online (Sandbox Code Playgroud)
其中authOrDie函数的定义(在我的auth.js模块中):
exports.authOrDie = function(req, res, next) {
if (req.isAuthenticated()) {
return next();
} else {
res.send(403);
}
});
Run Code Online (Sandbox Code Playgroud)
现在,当用户未经过身份验证时,我想验证http请求是否具有授权(基本)标头.为此,我想使用伟大的连接中间件basicAuth().
如您所知,Express建立在Connect之上,因此我可以使用express.basicAuth.
在basicAuth一般使用这样的:
app.get('/', express.basicAuth(function(username, password) {
// username && password verification...
}), function(req, res) {
res.send();
});
Run Code Online (Sandbox Code Playgroud)
但是,我想在我的authOrDie函数中使用它:
exports.authOrDie = function(req, res, next) {
if (req.isAuthenticated()) {
return next();
} else if {
// express.basicAuth ??? ******
} else {
res.send(403); …Run Code Online (Sandbox Code Playgroud) 说如果我想输入
[Name] [Name]
Run Code Online (Sandbox Code Playgroud)
我将如何检测
[Name] [Name] [Name]
Run Code Online (Sandbox Code Playgroud)
并返回错误?
这是我到目前为止的一切
char in[20];
char out[20];
scanf(" %s %s", out, in);
Run Code Online (Sandbox Code Playgroud) c ×2
javascript ×2
python ×2
annotations ×1
class ×1
coding-style ×1
connect ×1
convention ×1
express ×1
forms ×1
get ×1
java ×1
jquery ×1
maven ×1
node.js ×1
php ×1
redis ×1
scope ×1
setuptools ×1
tablegateway ×1