小编Ale*_*dar的帖子

如何格式化golang中的持续时间

我有以下代码,我无法在游戏中运行因为我使用gin框架和filewalk.

package main

import (
    "fmt"
    "os"
    "path/filepath"
    "time"
    "regexp"
    "github.com/gin-gonic/gin"
    "sort"
    "strings"
    "github.com/davidscholberg/go-durationfmt"
)

var filext = regexp.MustCompile(`\.[mM][pP]4|\.[mM]4[vV]|\.jpg|\.[hH]264|\.go`)
var m map[int]string
var keys []int

func main() {

    if gin.IsDebugging() {
        fmt.Print("This progamm shows only the path and the age of a file in 'STARTDIR'\n")
        fmt.Print("only the following files will be handled '.[mM][pP]4|.[mM]4[vV$|.[hH]264|.go'\n")
        fmt.Print("The git repository: https://gitlab.com/aleks001/show-files-age \n")
    }

    if len(os.Getenv("LISTEN_IP_PORT")) == 0 {
        fmt.Print("I need a ip and port on which I should listen.\n")
        os.Exit(1)
    }
    router := gin.Default() …
Run Code Online (Sandbox Code Playgroud)

go

9
推荐指数
4
解决办法
1万
查看次数

将Perl语法转换为Python

我有一个文件,其中的行由空格分隔.

我在Perl中编写了以下程序并且它可以工作.现在我必须用Python重写它,这不是我的语言,但我已经或多或少地解决了它.

我目前在Perl中使用这个表达式很困难,我无法将其转换为Python.

$hash{$prefix}++;
Run Code Online (Sandbox Code Playgroud)

我找到了一些解决方案,但我没有足够的Python经验来解决这个问题.与Perl相比,所有解决方案对我来说都很复杂.

这些Stack Overflow问题似乎是相关的.

Python变量作为dict的键

Python:如何从函数变量中将键传递给字典?

Perl的

#!perl -w

use strict;
use warnings FATAL => 'all';

our $line = "";
our @line = "";
our $prefix = "";
our %hash;
our $key;

while ( $line = <STDIN> ) {
  # NAMESPACE                NAME                                         READY     STATUS             RESTARTS   AGE       IP               NODE
  next if $line =~ /^NAMESPACE/;

  #aleks-event-test         redis-1-m06k0                                1/1       Running            0          1d        172.26.0.138     The_Server_name
  @line = split ' ', $line;
  $line[1] =~ /(.*)-\d+-\w+$/ ;
  $prefix = $1;
  #print "$prefix $line[7]\n"; …
Run Code Online (Sandbox Code Playgroud)

python migration perl

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

标签 统计

go ×1

migration ×1

perl ×1

python ×1