python菜鸟一问,请大大们解答,谢谢

Python017

python菜鸟一问,请大大们解答,谢谢,第1张

哥们,需要import string:

>>>import string

>>>string.atoi('10') + 4

14

分析:错误原因说,name 'string' is not defined,意思是string没有定义。。。所以import一下就好啦。。

#!/bin/env python

x = 16

ans = 0

while ans * ans < x:

    ans+=1

    print ans

python对语句写的格式要求比较严格,尤其是四个空格。

不知道你print是想放到while里面还是外面,姑且我认为是放到里面。