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 ...
随机推荐
- javascript实现文字逐渐显现
下面是文字逐渐显现的JS代码<pre id="wenzi"></pre><div style="display:none" id= ...
- redis、mysql、mongdb的比较
特点: 1-1 MySQL:1. 使用c和c++编写,并使用了多种编译器进行测试,保证源代码的可移植性2. 支持多种操作系统3. 为多种编程语言提供可API4. 支持多线程,充分利用CPU资源优化的S ...
- Apache ab 压力并发测试工具
当你使用PHP(或其他编程语言)完成一个web程序的开发,并且web程序在Apache服务器上正常运行的时候,你有没有考虑过对你的Apache服务器及部署在其上的web程序进行一些压力测试呢?毕竟,真 ...
- 134. Gas Station加油站
[抄题]: There are N gas stations along a circular route, where the amount of gas at station i is gas[i ...
- Sonar+maven+jenkins集成,Java代码走查
Sonar服务在Sonar安装与使用篇已经介绍过,此文章不再说了 Jenkins的安装与配置方法参考http://www.cnblogs.com/chenchen-tester/p/6408815.h ...
- 用ps增加照片的气氛--镜头光晕
1.寻找一张图片 2.新建一个图层填充为黑色 3.选择滤镜---渲染---镜头光晕 4.选择图层模式---滤色. 编辑:千锋UI设计
- AndroidStudio 3 export jar file
1. File -> New -> New Module -> Android Library 例子中暂命名ModuleA 2. 修改刚创建 ModuleA下的build.gra ...
- 《C#从现象到本质》读书笔记(五)第5章字符串第6章垃圾回收第7章异常与异常处理
<C#从现象到本质>读书笔记(五)第5章字符串 字符串是引用类型,但如果在某方法中,将字符串传入另一方法,在另一方法内部修改,执行完之后,字符串的只并不会改变,而引用类型无论是按值传递还是 ...
- Win7 VS2015 NASM汇编语言环境配置
参考了以下两个博客文章 http://blog.csdn.net/x356982611/article/details/51260841 http://www.cnblogs.com/antonioz ...
- crontab定时时间解释
用户所建立的crontab文件中,每一行都代表一项任务,每行的每个字段代表一项设置,它的格式共分为六个字段,前五段是时间设定段,第六段是要执行的命令段,格式如下: minute hour day mo ...