私が取り組んでいるプロジェクトの目覚まし時計の部分(コーヒー淹れ目覚し時計)のためにこのコードを書いています。私はどちらかのプログラムを実行すると、単に「む〜...」の部分にスキップしたり、エラーを返すラズベリーパイプロジェクトのPython目覚まし時計のコードの問題
AttributeError: 'str' object has no attribute 'start'
誰もがこの固定取得する方法上の任意のアイデアや作業目覚まし時計を持っていますか?私はPythonにはまだまだ慣れていないし、コードをあまりにも長く見ているだけで、目の新鮮なセットが必要です。
import time
import os
import threading
class Alarm(threading.Thread):
def __init__(self, hours, minutes):
super(Alarm, self).__init__()
self.hours = int(hours)
self.minutes = int(minutes)
self.keep_running = True
def run(self):
try:
while self.keep_running:
now = time.localtime()
if (now.tm_hour == self.hours and now.tm_min == self.minutes):
print("ALARM NOW!")
os.popen("bensound-dubstep.mp3")
return
time.sleep(60)
except:
return
def just_die(self):
self.keep_running = False
print("Enter your name: ")
user_input=input(":")
print("Hello, " + user_input)
alarm_HH = input("Enter the hour you want to wake up at: ")
alarm_MM = input("Enter the minute you want to wake up at: ")
print(("You want to wake up at: " + alarm_HH + ':' + alarm_MM).format(alarm_HH, alarm_MM))
alarm=("class Alarm")
class Alarm (Alarm(alarm_HH, alarm_MM)):
alarm.start()
try:
while True:
text = str(user_input())
if text == "stop":
alarm.just_die()
break
except:
print("Yikes lets get out of here")
alarm.just_die()
はStackOverflowのへようこそ。あなたの質問のタイトルはあなたが持っている問題についてあまりにも多くを明らかにしていません。あなたはそれを改善できますか?また、[良い質問をするにはどうすればいいですか?](http://stackoverflow.com/help/how-to-ask)と[最小完全検証可能な例(http://stackoverflow.com/help/mcve)あなたの問題の –