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 ...
随机推荐
- IO 、NIO、AIO
Java 中的流 https://ifeve.com/java-nio-vs-io/
- MyBatis :Insert (返回主键、批量插入)
一.前言 数据库操作怎能少了INSERT操作呢?下面记录MyBatis关于INSERT操作的笔记,以便日后查阅. 二.insert元素 属性详解 其属性如下: parameterType , ...
- python 函数编程
def test1(): print('in the test1') def test2(): print('in the test2') return 1 def test3(): print('i ...
- 微软Office Online服务安装部署(三)
现在开始配置两台服务器,两台服务器的IP: Server: 10.1.3.89 Client: 10.1.3.92 1.在Client中,.打开网络属性,找到ipv4的配置,将dns 改成域控制器的 ...
- Linux查看某个进程的线程
线程是现代操作系统上进行并行执行的一个流行的编程方面的抽象概念.当一个程序内有多个线程被叉分出用以执行多个流时,这些线程就会在它们之间共享特定的资源(如,内存地址空间.打开的文件),以使叉分开销最小化 ...
- spring入门--spring入门案例
spring是一个框架,这个框架可以干很多很多的事情.感觉特别吊.但是,对于初学者来说,很难理解spring到底是干什么的.我刚开始的时候也不懂,后来就跟着敲,在后来虽然懂了,但是依然说不明白它到底是 ...
- C++字符串结束标识
用一个字符数组可以存放一个字符串中的字符.如: char str[12]={'I',' ','a','m',' ','h','a','p','p','y'}; 用一维字符数组str来存放一个字符串″I ...
- 【APP测试(Android)】--性能测试
- s11.9 sar:收集系统信息
功能说明: 通过sar命令,可以全面地获取系统的CPU.运行队列.磁盘I/O.分页(交换区).内存.CPU中断和网络等性能数据. 语法格式 sar option interval count sar ...
- Nginx unit 源码安装初体验
Nginx unit 源码安装初体验 上次介绍了从yum的安装方法(https://www.cnblogs.com/wang-li/p/9684040.html),这次将介绍源码安装,目前最新版为1. ...