TypeError: 在字符串格式化过程中并非所有参数都被转换是什么意思?
这是我的第一个程序,它基本上以不同的声音大声说出内容:
import os
print "Hello, Welcome to the speaking program"
speak = raw_input("What would you like to say?\n")
type = raw_input("Would you like\n1. Normal Voice\n2. High Pitched\n3. Low Pitched?\n4. Whisper\n5. Indian Voice\n Please choose 1,2,3,4 or 5\n")
if type == "1":
os.system("say %s " % speak)
if type == "2":
os.system("say -v good %s" % speak)
if type == "3":
os.system("say -v bad %s" % speak)
if type == "4":
os.system("say -v whisper %s" % speak)
if type == "5":
os.system("say -v sangeeta $s" % speak)
if type < "5":
os.system("echo that is not an option")
finish = raw_input("I have done the job, Pick an option\n1. Quit\n2. New Word\n3. Change Pitch\n")
if finish == "1":
quit()
if finish == "2":
os.system("clear")
os.system("python speak.py")
if finish == "3":
type2 = raw_input("Would you like\n1. Normal Voice\n2. High Pitched\n3. Low Pitched\nor\n4. Whisper voice?\n5.Indian Voice\n")
if type2 == "1":
os.system("say %s " % speak)
if type2 == "2":
os.system("say -v good %s" % speak)
if type2 == "3":
os.system("say -v bad %s" % speak)
if type == "4":
os.system("say -v whisper %s" % speak)
if type == "5":
os.system("say -v Sangeeta %s" % speak)
else:
print "That is not an option"
os.system("clear")
os.system("python speak.py")
else:
print "That is not an option !!! "
os.system("clear")
os.system("python speak.py")
finish = raw_input("I have done the job, Pick an option\n1. Quit\n2. New Word\n3. Change Pitch\n")
if finish == "1":
os.system("logout")
os.system("killall Terminal")
if finish == "2":
os.system("clear")
os.system("python speak.py")
if finish == "3":
type3 = raw_input("Would you like \n1. Normal Voice\n2. High Pitched\n3. Low Pitched?\n4. Whisper voice\n5.Indian Voice\n")
if type3 == "1":
os.system("say %s " % speak)
if type3 == "2":
os.system("say -v good %s" % speak)
if type3 == "3":
os.system("say -v bad %s" % speak)
if type3 == "4":
os.system("say -v whisper %s" % speak)
if type3 == "5":
os.system("say -v Sangeeta %s" % speak)
else:
print "That is not an option"
os.system("clear")
os.system("python speak.py")
这就是错误:
Shameers-MacBook-Pro:Test Programs Shameer$ !!
python speak.py
Hello, Welcome to the speaking program
What would you like to say?
hello
Would you like
1. Normal Voice
2. High Pitched
3. Low Pitched?
4. Whisper
5. Indian Voice
Please choose 1,2,3,4 or 5
5
Traceback (most recent call last):
File "speak.py", line 16, in <module>
os.system("say -v sangeeta $s" % speak)
TypeError: not all arguments converted during string formatting
请帮助我。我还年轻,需要一些帮助。如果您不想回答,只会投反对票。
here is my first program it basically says stuff out loud and in different voices :
import os
print "Hello, Welcome to the speaking program"
speak = raw_input("What would you like to say?\n")
type = raw_input("Would you like\n1. Normal Voice\n2. High Pitched\n3. Low Pitched?\n4. Whisper\n5. Indian Voice\n Please choose 1,2,3,4 or 5\n")
if type == "1":
os.system("say %s " % speak)
if type == "2":
os.system("say -v good %s" % speak)
if type == "3":
os.system("say -v bad %s" % speak)
if type == "4":
os.system("say -v whisper %s" % speak)
if type == "5":
os.system("say -v sangeeta $s" % speak)
if type < "5":
os.system("echo that is not an option")
finish = raw_input("I have done the job, Pick an option\n1. Quit\n2. New Word\n3. Change Pitch\n")
if finish == "1":
quit()
if finish == "2":
os.system("clear")
os.system("python speak.py")
if finish == "3":
type2 = raw_input("Would you like\n1. Normal Voice\n2. High Pitched\n3. Low Pitched\nor\n4. Whisper voice?\n5.Indian Voice\n")
if type2 == "1":
os.system("say %s " % speak)
if type2 == "2":
os.system("say -v good %s" % speak)
if type2 == "3":
os.system("say -v bad %s" % speak)
if type == "4":
os.system("say -v whisper %s" % speak)
if type == "5":
os.system("say -v Sangeeta %s" % speak)
else:
print "That is not an option"
os.system("clear")
os.system("python speak.py")
else:
print "That is not an option !!! "
os.system("clear")
os.system("python speak.py")
finish = raw_input("I have done the job, Pick an option\n1. Quit\n2. New Word\n3. Change Pitch\n")
if finish == "1":
os.system("logout")
os.system("killall Terminal")
if finish == "2":
os.system("clear")
os.system("python speak.py")
if finish == "3":
type3 = raw_input("Would you like \n1. Normal Voice\n2. High Pitched\n3. Low Pitched?\n4. Whisper voice\n5.Indian Voice\n")
if type3 == "1":
os.system("say %s " % speak)
if type3 == "2":
os.system("say -v good %s" % speak)
if type3 == "3":
os.system("say -v bad %s" % speak)
if type3 == "4":
os.system("say -v whisper %s" % speak)
if type3 == "5":
os.system("say -v Sangeeta %s" % speak)
else:
print "That is not an option"
os.system("clear")
os.system("python speak.py")
and this is the error:
Shameers-MacBook-Pro:Test Programs Shameer$ !!
python speak.py
Hello, Welcome to the speaking program
What would you like to say?
hello
Would you like
1. Normal Voice
2. High Pitched
3. Low Pitched?
4. Whisper
5. Indian Voice
Please choose 1,2,3,4 or 5
5
Traceback (most recent call last):
File "speak.py", line 16, in <module>
os.system("say -v sangeeta $s" % speak)
TypeError: not all arguments converted during string formatting
Please help me. I am young and need some help. Will only down vote if you aren't trying to answer.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您输入美元符号而不是百分号:
这应该是:
You put a dollar sign instead of a percent sign:
This should be: