Python:raw_input读取数字的问题

yos*_*osh 7 python raw-input

不幸的是raw_input没有做我需要它做的事情.我想要做的是获取totPrimes =我在提示符下键入的内容.如果我while count < totPrimeswhile count < 50这个脚本替换工作.如果我在提示符下键入50,这个脚本不起作用,我担心raw_input不是我想要使用的函数吗?这是我的代码片段:

testNum = 3
div = 2
count = 1
totPrimes = raw_input("Please enter the primes: ")

while count < totPrimes :
    while div <= testNum :
Run Code Online (Sandbox Code Playgroud)

joa*_*uin 12

totPrimes = int(totPrimes)
while count < totPrimes:
    # code
Run Code Online (Sandbox Code Playgroud)

raw_input 给你一个字符串,你必须在进行任何数字比较之前转换为整数或浮点数.