使用winsound模块播放声音
import winsound
import math
s = """3345 1233345 234 431 434 -612 12334567 +1+1345 23434+1+1
23434+2+2 +17+1+2+3+277+1 +175516 651132 345+17+1+2+3+2 77+1+175516
655+17+1
"""
freq = 440
i = 0
while i < len(s):
c = s[i]
if str.isspace(s[i]):
i += 1
continue
print(c)
if c == '+':
c = int(s[i + 1]) - 6 + 7
i += 2
elif c == '-':
c = int(s[i + 1]) - 7 - 6
i += 2
else:
c = int(s[i]) - 6
i += 1
f = int(freq * math.pow(2, 1 / 7 * c))
winsound.Beep(f, 500)
使用winsound模块播放声音的更多相关文章
- python winsound模块
(目标:出现交易下单.结束成交.数据中断等信号的时候,PC 发出声音提醒.) python winsound模块 winsound是Python的内置包,无需下载.可以直接通过 import wins ...
- python 各模块
01 关于本书 02 代码约定 03 关于例子 04 如何联系我们 1 核心模块 11 介绍 111 内建函数和异常 112 操作系统接口模块 113 类型支持模块 114 正则表达式 115 语言支 ...
- python模块大全
python模块大全2018年01月25日 13:38:55 mcj1314bb 阅读数:3049 pymatgen multidict yarl regex gvar tifffile jupyte ...
- 让小乌龟可以唱歌——对Python turtle进行拓展
在Scratch中,小猫是可以唱歌的,而且Scratch的声音木块有着丰富的功能,在这方面Python turtle略有欠缺,今天我们就来完善一下. Python声音模块 Python处理声音的模块很 ...
- python第六天 函数 python标准库实例大全
今天学习第一模块的最后一课课程--函数: python的第一个函数: 1 def func1(): 2 print('第一个函数') 3 return 0 4 func1() 1 同时返回多种类型时, ...
- Pygame 加载音频
Python Learning:Pygame 加载音频 Python 中自带的 winsound 模块 winsound 模块中 Beep 方法可以调用系统的蜂鸣器,接受一个为 frequency 的 ...
- Python Standard Library
Python Standard Library "We'd like to pretend that 'Fredrik' is a role, but even hundreds of vo ...
- python——定时闹钟讲解
自己写的闹钟, 只可以播放wav格式的音频. import time import sys soundFile = 'sound.wav' not_executed = 1 def soundStar ...
- about云资源汇总指引V1.4:包括hadoop,openstack,nosql,虚拟化
hadoop资料 云端云计算2G基础课程 (Hadoop简介.安装与范例) 炼数成金3G视频分享下载 虚拟机三种网络模式该如何上网指导此为视频 Hadoop传智播客七天hadoop(3800元)视频, ...
随机推荐
- [Git] 技术的热门度曲线
reference :http://www.ruanyifeng.com/blog/2017/03/gartner-hype-cycle.html reference : https://stateo ...
- Gedit
Use Gedit as Remote File Editor via FTP and SSH Migrating from Windows Vista to Ubuntu 8.04 and have ...
- [leetcode]Copy List with Random Pointer @ Python
原题地址:https://oj.leetcode.com/problems/copy-list-with-random-pointer/ 题意: A linked list is given such ...
- Search in Rotated Sorted Array leetcode java
题目: Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 ...
- Raphael path 拖动实现
让 Raphael 的 Path 动起来 Raphaël 是一个很实用的线上矢量图操作 Javascript 库.使用简单,一个值得一提的卖点是通过抽象出共同的接口屏蔽了 SVG 和 VML 之间的差 ...
- mysql数据库查询优化
上两周一直想办法提高查询速度,取得一点效果,解决了部分问题,记下来以便将来自己查看. 由于公司没有专门的DBA,我自己对mysql数据库也不是很熟悉,而且这个JAVA开发的网络审计系统的管理系统,是经 ...
- jqGrid常用属性和方法介绍
jqGrid API中文手册:http://blog.mn886.net/jqGrid/ 一.jqGrid属性: width:Grid的宽度,如果未设置,则宽度应为所有列宽的之和:如果设置了宽度,则每 ...
- JavaScript Event Delegation, and event.target vs. event.currentTarget
原文:https://medium.com/@florenceliang/javascript-event-delegation-and-event-target-vs-event-currentta ...
- mongo文本搜索的一个例子
假如有一个名为articles的集合,数据如下: { "_id" : 1, "title" : "cakes and ale" } { ...
- [Backbone] Working with forms
Our first step is to add a template to the AppointmentForm below. Have the template produce a form w ...