|
发表于 2020-5-1 21:05:33
|
显示全部楼层
本楼为最佳答案
你应该是说 randint() 和 isdigit() 吧。首先 isdigit() 是字符串的方法,它使用前必须加上 str. ,str 代表字符串对象,英文点号表示 isdigit() 方法是属于字符串的,所以应该:
- >>> help(str.isdigit)
- Help on method_descriptor:
- isdigit(self, /)
- Return True if the string is a digit string, False otherwise.
-
- A string is a digit string if all characters in the string are digits and there
- is at least one character in the string.
复制代码
randint() 是属于 random 模块的函数,需要先从 random 模块中导入:
- >>> from random import randint
- >>> help(randint)
- Help on method randint in module random:
- randint(a, b) method of random.Random instance
- Return random integer in range [a, b], including both end points.
复制代码 |
|