【发布时间】:2011-05-29 01:30:57
【问题描述】:
文档http://docs.python.org/library/wave.html 说
Wave_read.readframes(n)
读取并返回最多 n 帧音频,作为字节串。
我想以十六进制或数字形式查看这些字符串,以了解当没有声音或加号、减号时的值
我试过了
import wave
target = wave.open('t2.wav')
length = target.getnframes()
section = target.readframes(2205)
print section[0:2]
这个代码打印字符串看起来像+,当我运行代码时,
print int(section[0:2])
加薪
Traceback (most recent call last):
File "D:/py/pitch2.py", line 5, in <module>
print int(section[0:2])
ValueError: invalid literal for int() with base 10: '\x10'
如何解决?
【问题讨论】:
标签: python string printing hex