【发布时间】:2014-06-09 19:48:42
【问题描述】:
我是一个新手程序员,我似乎无法弄清楚这一点。我输入的这段代码出现错误。请注意,这是在 Linux 上(准确地说是 Raspberry Pi)。
direct = raw_input("\nPlease give the the directory or your song ending with the file type \nEX. /folder1/favoritesong.WAV"
#ftype - file type
#ftype 1 - WAV file
#ftype 2 - mp3 file
ftype11 = ".WAV" in direct
ftype12 = ".wav" in direct
ftype21 = ".mp3" in direct
ftype22 = ".MP3" in direct
if ftype11 or ftype12 == True:
if ftype11 == True:
os.system("clear")
print "Does the song sound to fast, slow, or just not playing at all? Check the README files."
check1 = os.system("sudo ./pifm " + direct + " " + str(freq) + " 22050 stereo")
print check1
elif ftype11 == False:
if ftype12 == True:
os.system("clear")
print "Does the song sound to fast, slow, or just not playing at all? Check the README files."
check1 = os.system("sudo ./pifm " + direct + " " + str(freq) + " 22050 stereo")
print check1
else:
time.sleep(3.5)
print "error 256"
print error256
time.sleep(2)
quit()
elif ftype11 or ftype12 == False:
if ftype21 == True:
print good
elif ftype21 == False:
if ftype22 == True:
print good
else:
time.sleep(3.5)
print "error256"
print error256
time.sleep(2)
quit()
如果您需要,这是我的完整代码,提前非常感谢。
https://docs.google.com/document/d/1Pjk2MFAKwJzPoFvNXB7DWdrCMEnwnU7Y-oYoKAWcv_0/edit?usp=sharing
【问题讨论】:
-
您在
.WAV"结束后缺少) -
像pastebin 这样的网站更适合共享代码,因为它为读者提供语法高亮以增加可读性。
-
@D4nC00per:堆栈溢出策略是在问题中包含代码;不鼓励将代码链接到另一个站点。我不确定 Pastebin 的语法高亮与 StackOverflow 相比如何,但不让代码根据其他网站的命运或删除策略消失的好处被认为很重要。
-
抱歉,只是不想在一页上有一大堆代码。无论如何,感谢您发现这一点,下次我会毫不犹豫地使用 pastebin。谢谢@D4nC00per
标签: python linux python-2.7 syntax-error raspberry-pi