如何使用Klepto包Python

时间:2018-06-01 13:21:08

标签: python directory pickle archive klepto

Hellow World!

我有一个pickle文件(包含字节形式的图像)要打开但是当我用pickle打开它时我得到这个错误:

public class Facts {
private boolean mAnswers;
private String mFacts;
private String mDialog;

public Facts(boolean mAnswers, String mFacts, String mDialog) {
    this.mAnswers = mAnswers;
    this.mDialog = mDialog;
    this.mFacts = mFacts;
}

public boolean ismAnswers() {
    return mAnswers;
}

public String getmFacts() {
    return mFacts;
}
public String getmDialog(){
    return mDialog;
}
}

我被告知要改用klepto。这是我的尝试,但当我加载并尝试打印数据时,它打印出来#34;无"

class App extends React.Component {
  state = { val: "", oddeven: "" }

  handleChange = e => {
    this.setState({ val: e.target.value })
  }

  OddEven = () => {
    const number = parseInt(this.state.val) //Use the state directly
    let description
    if (Number.isInteger(number)) {
      if (number % 2 == 0) {
        description = <strong>even</strong>
      } else {
        description = <i>odd</i>
      }
      alert(number)
      this.setState({ oddEven: "Hello" })
    } else {
      return null
    }
  }

  render() {
    return (
      <div>
        <input type="text" onChange={this.handleChange} />
        <button onClick={this.OddEven}>Odd Even</button> {/* you do not need to passs the state here, you can directly access it in your function */}
        {this.state.oddEven && <h1>{this.state.oddEven}</h1>}  {/* Here we check if oddEven exists and then we display whatever we set in the OddEven function}
      </div>
    )
  }
}

这是输出:

Traceback (most recent call last):
  File "test.py", line 20, in <module>
    if __name__ == "__main__": main()
  File "test.py", line 10, in main
    dump = pickle.load(file)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xff in position 0: ordinal not in range(128)

非常感谢任何建议

0 个答案:

没有答案