TypeError: unsupported operand type(s) for /: 'str' and 'str'

后端 未结 4 1672
说谎
说谎 2020-11-27 21:44
name = input(\'Enter name here:\')
pyc = input(\'enter pyc :\')
tpy = input(\'enter tpy:\')
percent = (pyc / tpy) * 100;
print (percent)
input(\'press enter to quit\         


        
4条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-27 22:18

    By turning them into integers instead:

    percent = (int(pyc) / int(tpy)) * 100;
    

    In python 3, the input() function returns a string. Always. This is a change from Python 2; the raw_input() function was renamed to input().

提交回复
热议问题