直接看下面实例:

In [52]: output=subprocess.check_output(["head -c 16 /dev/urandom | od -An -t x | tr -d ' '"], shell=True) In [53]: print(output) b'3512c668547cd983cb48ccf05b0ccedf\n' In [67]: output.strip() Out[67]: b'3512c668547cd983cb48ccf05b0ccedf' In [72]: output.strip().strip('b') --------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-72-d12ac1d7dec8> in <module> ----> 1 output.strip().strip('b') TypeError: a bytes-like object is required, not 'str' In [70]: str(output.strip()).strip('b') Out[70]: "'3512c668547cd983cb48ccf05b0ccedf'"

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-09
  • 2021-08-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-31
  • 2022-12-23
  • 2022-12-23
  • 2021-09-12
  • 2021-09-28
  • 2022-03-03
  • 2022-12-23
相关资源
相似解决方案