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. dlib landmark+人面识别

    #include "stdafx.h" #include <dlib/image_processing/frontal_face_detector.h> #includ ...

  2. [Git] Git fetch和git pull的区别

    reference : http://blog.csdn.net/hudashi/article/details/7664457 Git中从远程的分支获取最新的版本到本地有这样2个命令:1. git ...

  3. MapReduce任务分析与讨论MapReduce job explained

    In the last post we saw how to run a MapReduce job on Hadoop. Now we're going to analyze how a MapRe ...

  4. C语言:字符串输出流输出文件中的数据。

    #include<stdio.h> #include<string.h> int main() { //定义文件指针 FILE *f = NULL; //打开文件 f = fo ...

  5. C++中List的用法

    Lists将元素按顺序储存在链表中. 与 向量(vectors)相比, 它允许快速的插入和删除,但是随机访问却比较慢. assign() 给list赋值 back() 返回最后一个元素 begin() ...

  6. python3之日期和时间(转载)

    转载:https://www.cnblogs.com/zhangxinqi/p/7687862.html a = datetime.datetime.now() time.sleep(10) b = ...

  7. Android -- PullToRefresh应用

    PullToRefresh 支持ListView.ExpandableListView.GridView.WebView 下载地址:https://github.com/chrisbanes/Andr ...

  8. cpu访址能力和内存

    这里有两个概念:cpu访址能力和提供的内存.举例来说,有个灯泡,可以照亮100立方米的空间,只有照亮的空间才可以工作.假如现在的空间只有50立方米,只要增加空间,可工作的空间就增加了.如果当前已经是1 ...

  9. jsAnim简单使用教程

    引入jsAnim.js 定义动画元素 元素需要有position:relative;或者position:absolute;属性 添加js <!DOCTYPE HTML> <html ...

  10. docker入门——构建镜像

    前面我们已经介绍了如何拉取已经构建好的带有定制内容的Docker镜像,那么如何构建自己的镜像呢? 构建Docker镜像有以下两种方法: 使用docker commit命令. 使用docker buil ...