can only concatenate tuple (not "int") to tuple问题原因
#测试程序
import os
from pydub import AudioSegment #已经确定, # enPath = "%s%s/%s"%(enDir,file,enfile) #英文文件的路径 # cnPath = "%s%s/%s"%(cnDir,file,enfile.replace("en_w","cn_w"))#中文文件的路径 path1 = "C:\\Users\\Administrator\\Desktop\\233春晓.mp3"
p1,f1=os.path.split(path1)
# sound1 = AudioSegment.from_file(path1, format=os.path.splitext(f1)[1][-3:]) sound1 = AudioSegment.from_mp3(path1) print(len(sound1))
sound_mix = AudioSegment.empty()
print(len(sound_mix))
data_play = ['', ',', '', '.', '', ',', '', '.', '', ',', '', '.']
time_end = int(data_play[0])*100
print(time_end)
# sound_mix = sound_mix + sound1[1,time_end]
sound_mix = sound1[0,3300]
print(len(sound_mix)) # song1 = AudioSegment.from_mp3(enPath) # song2 = AudioSegment.from_mp3(cnPath)
问题显示:
22544
0
3300
Traceback (most recent call last):
File "C:\Users\Administrator\OneDrive\Mufasa Code\audio lay\test_数据读取的音频合成.pyw", line 26, in <module>
sound_mix = sound1[0,3300]
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-packages\pydub\audio_segment.py", line 247, in __getitem__
end = millisecond + 1
TypeError: can only concatenate tuple (not "int") to tuple
请按任意键继续. . .
原因:
sound_mix = sound1[0,3300]
应该为数组类型
sound1[0:3300]
:::
can only concatenate tuple (not "int") to tuple问题原因的更多相关文章
- Python之创建tuple和“可变”的tuple
Python之创建tuple tuple是另一种有序的列表,中文翻译为" 元组 ".tuple 和 list 非常类似,但是,tuple一旦创建完毕,就不能修改了. 同样是表示班里 ...
- python产生错误:can only concatenate str (not "int") to str
代码为: #!/usr/bin/python # _*_ coding:utf-8_*_ # print("hello world!") name = input("na ...
- str int list tuple dict 一些实操
#字符串的 一些实操 a='what' b=' are ' c=' you ' print(a+b+c) #字符串拼接 m =a.split('+') #以什么分割 (代码a='w+ha+t' 输出[ ...
- Python中的数据结构 --- 元组(tuple)、字典(tuple)
元组(tuple)本身是不可变数据类型,没有增删改查:元组内可以存储任意数据类型一.元组的创建 例:t = (1,2.3,'star',[1,2,3]) ## 元组里面包含可变类型,故 ...
- 【问题记录】Python运行报错:can only concatenate str (not "int") to str
自己总是写程序时候用 + 拼接的时候忘记变量类型要一致,如下面 frame_num = "1" for i in range(1, frame_num + 1, 1): self. ...
- TypeError: can only concatenate str (not "int") to str解决方式
使用format函数解决问题 for page in range(1,pagebox+1): url = "https://www.dd373.com/s/rbg22w-x9kjbs-wwf ...
- Python元组(tuple)
元组(tuple)是Python中另一个重要的序列结构,与列表类型,也是由一系列按特定顺序排列的元素组成,但是他是不可变序列.在形式上元组的所有元素都放在"()"中,两个元素使用& ...
- C# Tuple<T1,T2....T>元组的使用
1) 先说组元:一个数据结构,由通过逗号分割的,用于传递给一个程序或者操作系统的一系列值的组合. NET Framework 直接支持一至七元素的元组 Tuple<T1> Tuple< ...
- Tuple<T1,T2,.........T> 元组简单使用
元组:一个数据结构,逗号分隔,用于传递一个程序或者操作系统的一系列值得组合 NET Framework直接支持一至七元素得数组 Tuple<T1> Tuple<T1,T2> T ...
随机推荐
- 100-days: fifteen
Title: Disney(迪士尼) moves from behemoth to colossus with closing(使…结束,使停止) of Fox(福克斯) deal(商业上的交易/协议 ...
- load 过高分析办法
1.top -H 找到占用cpu较高的进程2.top -Hp pid 找到该进程下占用cpu较高的线程id3.sudo -u adminjstack -F 进程id > ~/stack.txt ...
- jfinal处理完html提交过来的数据,将处理信息返回给html页面。html根据返回值进行相应的处理
1.前台jQuery代码: $.ajax({ url: "/admin/jcsjpz/syxmdy/RemoveSyxm", data: {data: id}, success: ...
- SpringMVC Http请求工具代码类
在SpringMVC的源代码中也提供了一个封装过的ThreadLocal,其中保存了每次请求的HttpServletRequest对象,(详细请看org.springframework.web.con ...
- 最近素数问题——C语言
从键盘输入一个整数,输出距离该数最近的素数 #include<stdio.h> #include<math.h> int judge(int x) { //判断素数 if (x ...
- linux学习第七天 (Linux就该这么学)
今天讲了chmod (权限 设置)和 chown(属性 设置),特殊权限:SUID u+s 数字法是4 x=s - = S,SGID g+s 数字法是2 x=s -=S,SBIT o+t x=t ...
- frp使用笔记
参考文档: https://github.com/fatedier/frp/blob/master/README_zh.md#%E9%80%9A%E8%BF%87-frpc-%E6%89%80%E5% ...
- bgfx入门练习2——找出DX,OpenGL驱动切换实现原理
找到驱动切换的代码,自然而然就要找实现的位置了,简单搜了下,原来是GLSL Shader字节码转换到HLSL字节码,正好和Klayge做了相反的工作. 时间上似乎也差不多,Klyage是2014年搞的 ...
- Hdp安装问题杂解
5.在安装的时候遇到的问题 5.1使用ambari-server start的时候出现ERROR: Exiting with exit code -1. 5.1.1REASON: Ambari Ser ...
- Oracle DBLINk的使用
Oracle中自带了DBLink功能,它的作用是将多个oracle数据库逻辑上看成一个数据库,也就是说在一个数据库中可以操作另一个数据库中的对象,例如我们新建了一个数据database1,我们需要操作 ...