1. 手动创建文件
在任意地点创建一个 .txt 文件,只要保证后续 .py 文件和该 .txt 文件在同一目录即可。
文件内容如下:
1,2,3,4,5,6,7,8,9,0
0,9,8,7,6,5,4,3,2,1
python,c++,c,java,c#,html,css,javascript,php
社会,公正,民主,法治,文明,友善,和谐

在任意地点创建一个 .txt 文件,只要保证后续 .py 文件和该 .txt 文件在同一目录即可。
文件内容如下:
1,2,3,4,5,6,7,8,9,0
0,9,8,7,6,5,4,3,2,1
python,c++,c,java,c#,html,css,javascript,php
社会,公正,民主,法治,文明,友善,和谐
大模型接入对战!
目的: 使我们纯python项目,可以融合其他功能。学会利用现有的 Python 基础,扩展新的功能。对于自己来说,要掌握快速上手新技术的能力。
核心点:
代码实现 🌟
原理探索探究 🌟🌟
实现思想 🌟🌟🌟
要知道如何向大模型接力,如何跟大模型交互、对话。这些无关代码、原理。作为“各个厂家大模型的调用者”要怎么去安排工作流程、分配任务等。
Impact of auditory attention decoding accuracy on noise reduction systems for hearing aids (2026)
[Biomedical Signal Processing and Control] SCIE,中科院2区(大类:医学;小类:工程:生物医学)
Hearing aid users often struggle to focus on a specific target speaker in multi-talker environments. Auditory attention decoding (AAD) algorithms, which extract attentional cues from electroencephalogram (EEG) signals, offer a potential solution. This study evaluates how AAD accuracy and decision window length affect the performance of a multichannel Wiener filter noise reduction system in a speaker and story-independent scenario. Simulations in two-speaker anechoic conditions show that, for decision windows of 1 s or less, AAD accuracies approximately above 81 % are required to meet minimum conversational speech quality (PESQ = 2.0), while accuracies approximately above 64 % suffice for intelligibility (STOI = 0.62). These results define quantitative performance targets for integrating AAD-based noise reduction into hearing aids and highlight the trade-off between decision latency, decoding accuracy, and perceptual benefit under idealized beamforming/VAD and anechoic conditions with high-density EEG.
EEG-based detection of the locus of auditory attention with convolutional neural networks (2021)
In a multi-speaker scenario, the human auditory system is able to attend to one particular speaker of interest and ignore the others. It has been demonstrated that it is possible to use electroencephalography (EEG) signals to infer to which speaker someone is attending by relating the neural activity to the speech signals. However, classifying auditory attention within a short time interval remains the main challenge. We present a convolutional neural network-based approach to extract the locus of auditory attention (left/right) without knowledge of the speech envelopes. Our results show that it is possible to decode the locus of attention within 1–2 s, with a median accuracy of around 81%. These results are promising for neuro-steered noise suppression in hearing aids, in particular in scenarios where per-speaker envelopes are unavailable.
设置-系统-系统信息-高级系统设置 ,找到右下角的环境变量。Path 。若没有所需版本,推荐官网下载安装包(次新版本)!
32/64 位根据 此电脑-属性 查看的系统情况选择。
安装程序启动,该页面选择 add python.exe to PATH 。
windows + R 再输入 cmd 打开电脑命令提示符。
思路:以玩家为中心,其他的信息都当做可以赋值的变量。
import random
class Game():
# 初始化玩家姓名、HP、敌人HP
def __init__(self, player_name):
self.player_name = player_name
self.player_hp = 100 # 直接在类和函数内部确定了玩家和敌人的血量
self.enemy_hp = 80 # 在确定敌人的血量同时,敌人姓名固定为 enemy
# 玩家操作攻击/防守
def actions(self):
self.action = input('Attack or Defense (A/D):')
if self.action == 'A':
self.enemy_hp -= random.randint(1, 20) # 玩家攻击,敌人血量减少
if self.enemy_hp <=0: # 敌人血量归零时用 return 停止
return
self.player_hp -= random.randint(1, 20) # 每回合敌人一定攻击,玩家正常减血就行
elif self.action == 'D':
self.player_hp -= random.randint(1, 20)/10 # 玩家防守,减血量为原本的 1/10
else:
print('Invalid action')
# main
player_name = input('请输入玩家姓名:')
player1 = Game(player_name) # 创建实例并完成初始化
while player1.player_hp > 0 and player1.enemy_hp >0:
# 显示玩家和敌人血量
print(f'{player1.player_name} HP: {player1.player_hp:.2f}')
print(f'Enemy HP: {player1.enemy_hp:.2f}')
# 调用操作函数,玩家选择攻击/防守
player1.actions()
if player1.player_hp > 0:
print('You win!')
else:
print('You lose!')
# ---output---
请输入玩家姓名:Ran
Ran HP: 100.00
Enemy HP: 80.00
Attack or Defense (A/D):A
Ran HP: 91.00
Enemy HP: 61.00
Attack or Defense (A/D):A
Ran HP: 79.00
Enemy HP: 48.00
Attack or Defense (A/D):A
Ran HP: 70.00
Enemy HP: 30.00
Attack or Defense (A/D):D
Ran HP: 68.80
Enemy HP: 30.00
Attack or Defense (A/D):D
Ran HP: 68.10
Enemy HP: 30.00
Attack or Defense (A/D):D
Ran HP: 67.60
Enemy HP: 30.00
Attack or Defense (A/D):A
Ran HP: 47.60
Enemy HP: 27.00
Attack or Defense (A/D):A
Ran HP: 40.60
Enemy HP: 26.00
Attack or Defense (A/D):A
Ran HP: 25.60
Enemy HP: 23.00
Attack or Defense (A/D):A
Ran HP: 7.60
Enemy HP: 8.00
Attack or Defense (A/D):D
Ran HP: 7.00
Enemy HP: 8.00
Attack or Defense (A/D):D
Ran HP: 6.60
Enemy HP: 8.00
Attack or Defense (A/D):A
You win!
此处可以回忆对战游戏里接入 API 模型的操作,那么 main.py 函数是否还需要修改?—— 不需要修改,只要保证 main.py 可以正常的接收大模型返回的特定结果即可。
我们只需要保证,使用任何大模型时返回的结果、类型与先前的大模型一致,即可无损实现!
在链接大模型的时候,我们需要了 try … except ,这一部分进行详细讲解。
Python 的语法错误称之为解析错,是初学者经常碰到的,如下实例:
>>> while True print('Hello world')
#------ output ------
File "D:\Coder\test 1\test5.py", line 1
while True print('Hello world')
^
SyntaxError: invalid syntax