python - 通过子进程python运行praat脚本时无法将字节输出转换为字符串
问题描述
sound_offset_time = subprocess.check_output(praat_command_str, shell=True).decode("utf-8")
给出输出
# Result: - #
另一个命令
process = subprocess.Popen(praat_command_str, stdout=subprocess.PIPE, stderr=None, shell=True)
给出输出:
('-\x006\x00.\x008\x001\x004\x006\x006\x000\x008\x009\x006\x003\x001\x007\x006\x006\x002\x00\r\x00\n\x00', None)
我无法从字节转换为字符串,仍然获得'-'。正确的输出,如果从命令行运行是
-6.814660896317662
解决方案
看起来您的命令正在以utf-16
形式发送输出,但您正试图将其解码为utf-8
.
推荐阅读
- apache - 主文档根的域指向新启用的子域文档根
- c# - 我可以说事件和委托之间的关系采用复合模式吗?
- python - NDI(网络设备接口)与 Python
- laravel - 如何通过中间表定义 Laravel Eloquent 关系
- python - 根据 ParentModel 中的 Total 验证 InlineFormSet 的总和
- java - 有人可以指出代码“满足给定总和条件的子序列数”的错误,这会导致堆栈溢出错误
- activemq - 即使 usePrefetchExtension 为 true,消费者也无法接收消息
- ios - 更改 googleMaps 当前位置图标/标记的颜色
- r - 如何在数据框R中选择区域/多边形(纬度,经度)
- javascript - Stripe Firefox Chrome 扩展重定向 URL 不起作用