小编Dan*_*Lee的帖子

http - > Google Kubernetes引擎中的https重定向

我正在寻找重定向所有流量

http://example.com - > https://example.com就像几乎所有网站一样.

我看过这个链接没有成功: Kinersnetes在Google容器引擎中使用HTTPS Ingress

并在我的ingress.yaml文件中尝试了以下注释.

nginx.ingress.kubernetes.io/configuration-snippet: |
  if ($http_x_forwarded_proto != 'https') {
    return 301 https://$host$request_uri;
  }
nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
nginx.ingress.kubernetes.io/ssl-redirect: "true"
kubernetes.io/ingress.allow-http: "false"
Run Code Online (Sandbox Code Playgroud)

一切都没有成功.为了清楚起见,我可以访问https://example.comhttp://example.com而没有任何错误,我需要http调用重定向到https.

谢谢

google-compute-engine google-cloud-platform kubernetes google-kubernetes-engine

10
推荐指数
4
解决办法
4826
查看次数

typehints - >无或留空

使用python 3,可以选择使用typehints.

我的问题是,如果一个函数返回None,应该添加一个,还是留空.

def hint(p:str) -> None:
    pass

def no_hint(p:str):
    pass
Run Code Online (Sandbox Code Playgroud)

哪个PEP解决了这个问题?

python python-3.x typehints

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

Python检测替代峰值

我有以下信号数据:

模式

信号为红色,滚动平均值为灰色.

我想找到一种方法来识别指数,其中在一个thresold值内的均值周围有连续的正负峰值.

例如,对于0,08的thresold,它将检测到22,35,36,第二个标记......

我不知道如何检测这些峰值.有人已经有这个用例吗?

python signal-processing

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

守则不好 第一个参数给了 super

在通过codacy审查一些代码时,Codacy给出了以下代码的问题:

def MyClass(OldClass):
    def __init__(self, arg1, arg2, *args, **kwargs)
        self.arg1 = arg1
        self.arg2 = arg2
        super(OldClass, self).__init__(*args, **kwargs)
Run Code Online (Sandbox Code Playgroud)

解释如下:

为什么这是一个问题?

例如,使用基类作为第一个参数调用 super() 是错误的:

class AnotherOldStyleClass(OldStyleClass):
    def __init__(self):
        super(OldStyleClass, self).__init__() The super invocation 
Run Code Online (Sandbox Code Playgroud)

应该:

super(AnotherOldStyleClass, self).__init__()
Run Code Online (Sandbox Code Playgroud)

它似乎希望我这样做:

def MyClass(OldClass):
    def __init__(self, arg1, arg2, *args, **kwargs)
        self.arg1 = arg1
        self.arg2 = arg2
        super(OldClass, self).__init__(*args, **kwargs)
Run Code Online (Sandbox Code Playgroud)

或者也许是这样的:

def MyClass(OldClass):
    def __init__(self, arg1, arg2, *args, **kwargs)
        super(MyClass, self).__init__(*args, **kwargs)
        self.arg1 = arg1
        self.arg2 = arg2
Run Code Online (Sandbox Code Playgroud)

有人可以告诉我哪一个是正确的以及为什么这是首选行为?

作为参考,这里是我使用选项 2 找到的示例。

编辑:这是我的代码,因为它看起来完全一样。这解释了我的错误:

class TransferToBigQuery(GoogleCloudStorageToBigQueryOperator): …
Run Code Online (Sandbox Code Playgroud)

python optimization codacy

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

在“Range”上的“for”循环中允许“i”为“u64”

简单的问题,在任何地方都找不到答案:

for i in 0..65000000000 {
    do_something;
}
Run Code Online (Sandbox Code Playgroud)

抛出错误:

文字超出范围i32

将其设置为更大的类型也不起作用:

for i: u64 in 0..65000000000 {
    do_something;
}
Run Code Online (Sandbox Code Playgroud)

抛出错误:

错误:循环in中丢失for

rust

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