小编Hob*_*rou的帖子

如何从timedelta对象中删除微秒?

我计算平均时间,我想显示没有微秒的结果平均值.

avg = sum(datetimes, datetime.timedelta(0)) / len(datetimes)
Run Code Online (Sandbox Code Playgroud)

python format datetime timedelta

31
推荐指数
4
解决办法
2万
查看次数

如何使用Types :: Path :: Tiny with Moo

我在这个网站上的第一个问题,我来得很快.我是开发人员,我主要使用Python和Perl.我很有激情,我非常喜欢这个发展.

我的第一个问题是关于Perl,Moo和Type :: Tiny.Type :: Tiny当然是与Moo一起使用的一个很棒的模块,但我会在另一个问题上回到这个主题.

我发现了Types :: Path :: Tiny Moose和Moo的模块强制,所以我尝试在我的类中创建一个属性目录,就像文档中描述的一样,因为我的项目在Moose中工作,但是因为我搬进了Moo ,它不再有效:

package MahewinBlogEngine::Common;

use strict;
use warnings;

use feature "state";

use Moo;
use Types::Path::Tiny qw/Path AbsPath/;

use CHI;
use MahewinBlogEngine::Renderer;

use Type::Params qw( compile );
use Types::Standard qw( slurpy Object Str HashRef ArrayRef );


=attr directory

rw, required, Str. The directory contain articles.

=cut

has 'directory' => (
    is       => 'rw',
    isa      => AbsPath,
    required => 1,
    coerce   => 1,
);
Run Code Online (Sandbox Code Playgroud)

在我的测试目录中:

my $articles = MahewinBlogEngine->articles( …
Run Code Online (Sandbox Code Playgroud)

perl types moose coerce moo

5
推荐指数
1
解决办法
981
查看次数

Vimgrep不会打开在新缓冲区中找到的第一个匹配项

我曾经做过研究ag.vim.目前,它在第一次出现的缓冲区中打开文件,默认行为为vimgrep.我想知道是否有选项可以不这样做,并且能够在搜索后直接导航到快速列表.

谢谢

vim vimgrep

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

标签 统计

coerce ×1

datetime ×1

format ×1

moo ×1

moose ×1

perl ×1

python ×1

timedelta ×1

types ×1

vim ×1

vimgrep ×1