from socket import * # 网络接口函数模块
from time import ctime,sleep
import os # 操作系统模块
import threading # 线程操作模块
HOST = '127.0.0.1' # 服务器IP地址,采用本地地址
PORT = 21567 # UDP 端口
BUFSIZE = 1024 # 接收消息的缓冲区大小
ADDR = (HOST,PORT)
udpSerSock = socket(AF_INET, SOCK_DGRAM) #获得一个socket插口
udpSerSock.bind(ADDR) # 服务器UDP端口绑定
udpCliSock = socket(AF_INET, SOCK_DGRAM) # UDP 客户端socket,用于管理线程往服务线程发送消息
stopState = False # 服务线程停止状态字
songs = [
{ "歌曲名":"下一站天后","歌手":'twins',"语言":"粤语" },
{ "歌曲名":"风筝与风","歌手":'twins',"语言":"粤语" }
{ "歌曲名":'Dearest',"歌手":"滨崎步","语言":"日语" },
{ "歌曲名":"COLORS ~Melody and Harmony","歌手":"金在中","语言":"日语" },
{ "歌曲名":"hare the world","歌手":'TVXQ',"语言":"日语" },
{ "歌曲名":"In a different life","歌手":"沈昌珉","语言":"日语" }
]
theselectedsongs = []
def printMainMenu():
while True:
print "------------- 歌曲点播 --------------------"
print " 1: 查看全部歌曲 "
print " 2: 歌曲名搜索 "
print " 3: 歌手搜索 "
print " 4: 语言搜索 "
print " 5: 已点歌曲 "
print " 0: 退出 "
print "--------------------------------------------"
def mainThread():
while True:
printMainMenu()
choice = input("请输入你的选择 : ")
if choice == 1:
displayallsongs()
elif choice == 2:
accordingtothesong()
elif choice == 3:
chooselanguage()
elif choice == 0:
udpCliSock.sendto("退出",ADDR)
break
else:
pass
if __name__ == '__main__':
thread1 = threading.Thread(target=mainThread)
thread1.start()
把这个运行之和后就会出现首页一直疯狂运行 停不下来的界面
求问是哪里写错了(┬_┬)
from time import ctime,sleep
import os # 操作系统模块
import threading # 线程操作模块
HOST = '127.0.0.1' # 服务器IP地址,采用本地地址
PORT = 21567 # UDP 端口
BUFSIZE = 1024 # 接收消息的缓冲区大小
ADDR = (HOST,PORT)
udpSerSock = socket(AF_INET, SOCK_DGRAM) #获得一个socket插口
udpSerSock.bind(ADDR) # 服务器UDP端口绑定
udpCliSock = socket(AF_INET, SOCK_DGRAM) # UDP 客户端socket,用于管理线程往服务线程发送消息
stopState = False # 服务线程停止状态字
songs = [
{ "歌曲名":"下一站天后","歌手":'twins',"语言":"粤语" },
{ "歌曲名":"风筝与风","歌手":'twins',"语言":"粤语" }
{ "歌曲名":'Dearest',"歌手":"滨崎步","语言":"日语" },
{ "歌曲名":"COLORS ~Melody and Harmony","歌手":"金在中","语言":"日语" },
{ "歌曲名":"hare the world","歌手":'TVXQ',"语言":"日语" },
{ "歌曲名":"In a different life","歌手":"沈昌珉","语言":"日语" }
]
theselectedsongs = []
def printMainMenu():
while True:
print "------------- 歌曲点播 --------------------"
print " 1: 查看全部歌曲 "
print " 2: 歌曲名搜索 "
print " 3: 歌手搜索 "
print " 4: 语言搜索 "
print " 5: 已点歌曲 "
print " 0: 退出 "
print "--------------------------------------------"
def mainThread():
while True:
printMainMenu()
choice = input("请输入你的选择 : ")
if choice == 1:
displayallsongs()
elif choice == 2:
accordingtothesong()
elif choice == 3:
chooselanguage()
elif choice == 0:
udpCliSock.sendto("退出",ADDR)
break
else:
pass
if __name__ == '__main__':
thread1 = threading.Thread(target=mainThread)
thread1.start()
把这个运行之和后就会出现首页一直疯狂运行 停不下来的界面
求问是哪里写错了(┬_┬)
