小编Elo*_*ati的帖子

龙卷风 reverse_url()

我正在尝试在龙卷风中使用 reverse_url() 并且据我所知使用反向 url 我需要向 urls 列表添加一个名称(就像 Django)但是由于某种原因我在尝试运行服务器:

这是我的网址列表:

urls = [
    (r"/", IndexHandler, name="home"),
]
Run Code Online (Sandbox Code Playgroud)

这是我的 html:

<a class="navbar-brand navbar-right" href="{{reverse_url('home')}}">
Run Code Online (Sandbox Code Playgroud)

这是回溯:

Traceback (most recent call last):
File "tornado_server.py", line 4, in <module>
  from urls import urls
File "C:\Users\elong\Desktop\reblaze\4. ReactJS\react_tornado\urls.py", line 4
  (r"/", IndexHandler, name="home"),
                         ^
SyntaxError: invalid syntax
Run Code Online (Sandbox Code Playgroud)

任何想法我做错了什么?

python tornado

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

Boto3 - change_resource_record_sets 更改记录类型失败

我正在尝试使用boto3.change_resource_record_sets当前案例更新现有记录的类型,我正在尝试将记录从类型 A 更改为类型 CNAME - 具有匹配的值。

我收到以下错误:

botocore.errorfactory.InvalidChangeBatch:
An error occurred (InvalidChangeBatch) when calling the ChangeResourceRecordSets
operation: RRSet of type A with DNS name test.test.v3.prod.example.com.
is not permitted because a conflicting RRSet of type  CNAME with the same
DNS name already exists in zone test.v3.prod.example.com.
Run Code Online (Sandbox Code Playgroud)

此操作完全可以通过 AWS UI 完成(仅更新我试图从我的代码更新的同一区域中的记录)。

这是我的代码:

def update_record(zone_id):
  batch = {
    'Changes': [
      {
        'Action': 'UPSERT',
        'ResourceRecordSet' : {
          'Name' : 'test.test.v3.prod.example.com.',
          'Type' : 'CNAME',
          'TTL' : 15,
          'ResourceRecords' : [{'Value': 'www.example.com'}]
        }
      } …
Run Code Online (Sandbox Code Playgroud)

amazon-web-services amazon-route53 python-3.6

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

BigQuery标准SQL-不匹配正则表达式

我正在尝试创建一个查询,该查询将选择与给定正则表达式不匹配的所有内容

在旧版中,我们有REGEX_MATCH,所以我能够 WHERE x NOT REGEX_MATCH("[a-z]")

与标准SQL等效的是什么?

google-bigquery

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

通过路径获取字典键(字符串)

我有这条路可以不时改变:

'#/path/to/key'
Run Code Online (Sandbox Code Playgroud)

路径的各个部分未定义,因此该值也很好

'#/this/is/a/longer/path'
Run Code Online (Sandbox Code Playgroud)

我把这个键分成'/'所以我得到了

['#', 'path', 'to', 'key']
Run Code Online (Sandbox Code Playgroud)

我需要在这条路上找到钥匙,假设我的dict是exp,所以我需要到达这里:

exp['path']['to']['key']
Run Code Online (Sandbox Code Playgroud)

我怎么可能知道如何获得这个键?

python dictionary

0
推荐指数
2
解决办法
1368
查看次数

从firestore.DocumentRefence获取路径

有没有一种方法可以从文档引用和集合引用中获得指向它的路径?

当您创建文档引用时,您可以执行以下操作: db.document('your/document/reference/path') 并返回DocumentReference实例<class 'google.cloud.firestore_v1beta1.document.DocumentReference'>

我有相反的需要<class 'google.cloud.firestore_v1beta1.document.DocumentReference'>,我想得到路径your/document/refence/path

javascript python google-cloud-firestore

0
推荐指数
2
解决办法
1483
查看次数

获取字符串的开头,直到给定字符

我知道这是一个简单的问题,但我找不到答案。

我有这个字符串:

"M1[r2][r3]"
Run Code Online (Sandbox Code Playgroud)

我只想获取"M1",我正在寻找类似strchr() 函数的对象,该函数获取字符串并在a char处停止。

c

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