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模块播放声音的更多相关文章

  1. python winsound模块

    (目标:出现交易下单.结束成交.数据中断等信号的时候,PC 发出声音提醒.) python winsound模块 winsound是Python的内置包,无需下载.可以直接通过 import wins ...

  2. python 各模块

    01 关于本书 02 代码约定 03 关于例子 04 如何联系我们 1 核心模块 11 介绍 111 内建函数和异常 112 操作系统接口模块 113 类型支持模块 114 正则表达式 115 语言支 ...

  3. python模块大全

    python模块大全2018年01月25日 13:38:55 mcj1314bb 阅读数:3049 pymatgen multidict yarl regex gvar tifffile jupyte ...

  4. 让小乌龟可以唱歌——对Python turtle进行拓展

    在Scratch中,小猫是可以唱歌的,而且Scratch的声音木块有着丰富的功能,在这方面Python turtle略有欠缺,今天我们就来完善一下. Python声音模块 Python处理声音的模块很 ...

  5. python第六天 函数 python标准库实例大全

    今天学习第一模块的最后一课课程--函数: python的第一个函数: 1 def func1(): 2 print('第一个函数') 3 return 0 4 func1() 1 同时返回多种类型时, ...

  6. Pygame 加载音频

    Python Learning:Pygame 加载音频 Python 中自带的 winsound 模块 winsound 模块中 Beep 方法可以调用系统的蜂鸣器,接受一个为 frequency 的 ...

  7. Python Standard Library

    Python Standard Library "We'd like to pretend that 'Fredrik' is a role, but even hundreds of vo ...

  8. python——定时闹钟讲解

    自己写的闹钟, 只可以播放wav格式的音频. import time import sys soundFile = 'sound.wav' not_executed = 1 def soundStar ...

  9. about云资源汇总指引V1.4:包括hadoop,openstack,nosql,虚拟化

    hadoop资料 云端云计算2G基础课程 (Hadoop简介.安装与范例) 炼数成金3G视频分享下载 虚拟机三种网络模式该如何上网指导此为视频 Hadoop传智播客七天hadoop(3800元)视频, ...

随机推荐

  1. Composer使用体验

    什么是Composer 简单来说,Composer是PHP的包依赖管理器.但是Composer并不是类似于Yum.Apt的包管理器.Composer可以用于包或者第三方库的安装,但是可以选择在Proj ...

  2. Top N之MapReduce程序加强版Enhanced MapReduce for Top N items

    In the last post we saw how to write a MapReduce program for finding the top-n items of a dataset. T ...

  3. 第七章 JVM性能监控与故障处理工具(1)

    1.定位系统问题 依据 GC日志 堆转储快照(heapdump/hprof文件) 线程快照(threaddump/javacore文件) 运行日志 异常堆栈 分析依据的工具 jps:显示指定系统内的所 ...

  4. C/C++ 语言获取文件大小

    在C语言中测试文件的大小,主要使用二个标准函数. 1.fseek 函数原型:int fseek ( FILE * stream, long int offset, int origin ); 参数说明 ...

  5. go语言基础之init函数的介绍

    1.init函数的介绍 示例: 文件夹目录如下: 源代码: vi main.go   //程序入口 package main //必须 import ( "calc" " ...

  6. 查询分页-----强势top

    查询分页:语句1性能提升10倍多,仅仅是由于多了个topkeyword,非常不理解啊!!!! 1.查询时间1s内,r_object_id主键 select top 100 * from (  sele ...

  7. Mongo的安全验证

    参考如下的文档: https://docs.mongodb.org/manual/tutorial/enable-authentication/          1.1. 在启用匿名验证的情况下,创 ...

  8. [Algorithm] Print All Subsets of a Set

    Let's say given a number of array, you should print out, all the subet of this array. Example: [1, 2 ...

  9. [Debug] Debug Node.js Application by using Chrome Dev tools

    For example you have a server.js file, and you want to debug some problems; What you can do is: node ...

  10. 单点登录(SSO)(原创)

    单点登录(Single Sign On),简称为 SSO,是目前比较流行的企业业务整合的解决方案之一.SSO的定义是在多个应用系统中,用户只需要登录一次就可以访问所有相互信任的应用系统. 下面的sso ...