2019年7月29日

[Python] bytes 转换成 str

摘要: b = b"example" # bytes object s = "example" # str object sb = bytes(s, encoding = "utf8") # str to bytes 或者:sb = str.encode(s) # str to bytes bs = str(b, encoding = "utf... 阅读全文

posted @ 2019-07-29 10:44 liujx2019 阅读(2875) 评论(0) 推荐(0) 编辑

Python执行Linux cmd命令,获取输出的一种方法,输出是bytes

摘要: import subprocess p = subprocess.Popen('df -lh', stdout=subprocess.PIPE, shell=True) print(p.stdout.read()) 阅读全文

posted @ 2019-07-29 10:42 liujx2019 阅读(836) 评论(0) 推荐(0) 编辑

导航