未知速记标志:-E中的'E'

时间:2019-11-27 14:43:23

标签: python

我正在尝试在bash中执行python命令

我要执行的bash命令是:kubectl get ns | grep -E '(^|\s)OK($|\s)'

在python中,我这样做是这样的:

is_namespace_exists = subprocess.call(["kubectl", "get", "ns", "|", "grep", "-E", "\'(^|\s)"+NAMESPACE+"($|\s)\'"])

is_namespace_exists = subprocess.call(["kubectl", "get", "ns", "|", "grep", "-E", "'(^|\s)"+NAMESPACE+"($|\s)'"])

但是我得到这个错误:

  

未知速记标志:-E中的'E'

有人可以告诉我怎么了吗?

1 个答案:

答案 0 :(得分:1)

以下代码应该起作用:

import React,{useState} from "react";
import ReactDOM from "react-dom";

import "./styles.css";

function App() {
  const [count, setCount] = useState(0);
  const [count2, setCount2] = useState(0);
  return (
    <div className="App">
      Count: {count}
      <button onClick={() => setCount(0)}>Reset</button>
      <button onClick={() => setCount(prevCount => prevCount - 1)}>-</button>
      <button onClick={() => setCount(prevCount => prevCount + 1)}>+</button>
      <br/>
      <br/>
      Count: {count2}
      <button onClick={() => setCount2(0)}>Reset</button>
      <button onClick={() => setCount2(count2 - 1)}>-</button>
      <button onClick={() => setCount2(count2 + 1)}>+</button>
    </div>
  );
}

const rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);

基本上是this post的改编版。根据您的需求进行调整。