正在加载图片...
中国科学技术大学电子工程与信息科学系 ©2020 1.5.2 使用Python标准库 【例,标准库time】 import time,#引入time模块 ticks time.time() print"当前时间戳为:",ticks 【例,标准库os】 import os os.getcwd() #返回当前的工作目录 os.chdir(/server/accesslogs')#修改当前的工作目录 os.system('mkdir today') #执行系统命令nkdir 【例,标准库math】 import math math.cos(math.pi/4) 仅用于教学实验 math.log(1024,2) Python标准库提供了非常多的功能,详情可参阅 https://www.runoob.com/python3/python3-stdlib.html https://www.cnblogs.com/yfacesclub/p/10782601.html 学院 1.5.3 使用第三方的模块 1.5.3.1播放声音 信息科学 https://pythonbasics.org/python-play-sound/ #方法1琳snack sound kit from playsound import playsound playsound('audio.mp3') #方法3#snack sound kit from Tkinter import import tkSnack root=Tk() tkSnack.initializeSnack(root) snd tkSnack.Sound() snd.read('sound.wav') snd.play(blocking=1) #方法4#native player import os file="SOS.mp3" os.system("mpg123 "file) network @ustc.edu.cn中国科学技术大学电子工程与信息科学系 ©2020 network@ustc.edu.cn 1.5.2 使用 Python 标准库 【例,标准库 time】 import time; # 引入 time 模块 ticks = time.time() print "当前时间戳为:", ticks 【例,标准库 os】 import os os.getcwd() # 返回当前的工作目录 os.chdir('/server/accesslogs') # 修改当前的工作目录 os.system('mkdir today') # 执行系统命令 mkdir 【例,标准库 math】 import math math.cos(math.pi / 4) math.log(1024, 2) Python 标准库提供了非常多的功能,详情可参阅 https://www.runoob.com/python3/python3-stdlib.html https://www.cnblogs.com/yfacesclub/p/10782601.html 1.5.3 使用第三方的模块 1.5.3.1 播放声音 https://pythonbasics.org/python-play-sound/ ##方法 1## snack sound kit from playsound import playsound playsound('audio.mp3') ##方法 3## snack sound kit from Tkinter import * import tkSnack root = Tk() tkSnack.initializeSnack(root) snd = tkSnack.Sound() snd.read('sound.wav') snd.play(blocking=1) ##方法 4## native player import os file = "SOS.mp3" os.system("mpg123 " + file)
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有