【发布时间】:2017-12-22 07:10:02
【问题描述】:
所以我有一些在字符串末尾使用数字的变量。但是当我使用 str 函数时,“i”似乎没有转换为字符串。知道为什么会这样吗?
代码:
has_GroupConnection1 = True
has_GroupConnection2 = True
has_GroupConnection3 = True
GroupConnection1 = 45
GroupConnection2 = 88
GroupConnection3 = 55
for i in range(1,3):
if str(has_GroupConnection[i]) == True:
print(str(GroupConnection[i]))
【问题讨论】:
-
用列表替换
GroupConnection1、GroupConnection2和GroupConnection3。