|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
import random
num1 = random.randint(1,16)
num2 = random.sample(range(1,33),6)
# num1 = 6
# num2 = [12,13,14,15,16,17]
count = 0
temp1 = input('你选择的号码:')
"""将输入的字符串或数字等转换为列表(即数组)"""
temp1 = temp1.split(',')
temp2 = input('你选择的特殊号码:')
# for i in range(0,5):
# temp1 = int(temp1[i])
为什么我这里最后一行会报int的错啊:TypeError: 'int' object is not subscriptable
但是改成 temp1 = [int(temp1[i]) for i in range(len(temp1))] 就没错了
>>> s=map(int,input().split())
1 2 3 4 5
>>> s
<map object at 0x0000024D565CC040>
>>> list(s)
[1, 2, 3, 4, 5]
>>> int(list(s))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: int() argument must be a string, a bytes-like object or a number, not
'list'
>>>
|
|