【发布时间】:2014-03-30 18:13:00
【问题描述】:
下面的代码给了我错误,除了更改播放(winsound)声音的模块之外,这在 Windows 上的 Python2.6 上运行良好。不知道我在这个问题上哪里出错了。这是在 Linux 机器上运行的,以前是在 Windows 机器上运行的。 Windows 上的版本是 2.6,Linux 上的版本是 2.7.3。
Traceback(最近一次调用最后一次):文件“CallsWaiting.py”,第 9 行, 在 first_time = time.time() AttributeError: 'int' object has no attribute 'time'
import _mysql
import sys
import time
import os
import pygame
pygame.init()
time = 3
first_time = time.time()
last_time = first_time
while True:
pass
new_time = time.time()
if new_time - last_time > timeout:
last_time = new_time
os.system('cls')
iswaiting = 0
print "Calls Waiting: "
con = _mysql.connect(host='oip-prod', port=3308, user='admin', passwd='1234', db='axpdb')
con.query("select callswaiting from callcenterinformation where date - date(now()) and skillid = 2 order by time desc limit 1;")
result = con.user_result()
iswaiting = int('',join(result.fetch_row() [0]))
print "%s" % \
iswaiting
if iswaiting > 0:
print "Calls are waiting!"
pygame.mixer.init()
sounda = pygame.mixer,Sound("ring2.wav")
sounda.play()
【问题讨论】:
-
谢谢大家,简单的变量名错误...还在学习谢谢大家。
标签: python python-2.7