开发者

What does TypeError: not all arguments converted during string formatting mean in python

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":
开发者_JAVA技巧    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.


You put a dollar sign instead of a percent sign:

os.system("say -v sangeeta $s" % speak)

This should be:

os.system("say -v sangeeta %s" % speak)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜