首页 > 应用开发 > > python3 方法输出问题
import random
class myclass:
def mathdemo():
math = []
for i in range(10): #循环执行10 次
math.append(random.randint(1,100)) #随机生成1,100内的整数,并添加到math列表里
print(math)
#截取到该字符串的前面一位角标 正序从0开始,倒序从-1开始
#listdemo = [ 1,'string',[2,'demo'],45,'hello','word',2,5,6,8,12,47,21]
# print(listdemo[1:4])
# print(listdemo[0:5])
# print(listdemo[:-1])
# print(listdemo[2:-2])
# print(listdemo)
# print(math)hello=myclass.mathdemo()
print('--------------')
print(hello)
输出结果 :
[25, 81, 30, 61, 41, 71, 69, 42, 36, 28]
--------------
None
为毛输出是None ,方法执行结果不能复制么 0.0
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/1414/viewspace-3124068/ ,如需转载,请注明出处,否则将追究法律责任。