小编Nic*_*ckS的帖子

拆分一串一边的字母,一边是数字

我对这个问题一片空白.我收到格式的字符串.. AB1234 ABC1234 ABC123 AB12等等.基本上,航班号

他们可以有一到两个字母和1到5个数字.我想分割字符串,以便最终得到两个字符串,一个带数字,另一个带字母.

有任何想法吗?我看过这些,但看不到一个会做这个工作 https://www.dotnetperls.com/split-go

更新:

刚刚找到并将使用它,除非有更好的选择.删除所有字母/数字以创建所需的字符串https://golangcode.com/how-to-remove-all-non-alphanumerical-characters-from-a-string/

go

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

Lambda Golang PutItem 和 MarshalMap 到 DynamoDB

我正在尝试使用 Golang 将数据从 Lambda 加载到 DynamoDB 中,但是编组方法只是生成空项目。我有一个类型结构定义如下...

type Flight struct {
    id          string
    destination string
    airline     string
    time        string
    latest      string
}
Run Code Online (Sandbox Code Playgroud)

然后我填充一个切片如下.....

func PutToDynamo(Flights []Flight, kind string) {

Flights := []Flight{}

for _, row := range rows {
    columns := row.FindAll("td")

    f := columns[0].Text() //all these are strings
    a := columns[1].Text()
    i := columns[2].Text()
    t := columns[4].Text()
    l := columns[5].Text()

    flight := Flight{
        id:          i,
        destination: f,
        airline:     a,
        time:        t,
        latest:      l,
    }
    Flights = append(Flights, flight)
Run Code Online (Sandbox Code Playgroud)

然后我尝试加载到 …

go amazon-web-services amazon-dynamodb aws-lambda

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