dummy_list = ["1", "2", "3", "4"]
if 1 in dummy_list is [0]:
print ("it is the first element")
else:
print ("no it is not the first element")
我想检查一个列表,确定变量在列表中的位置是否在指定的区域内。现在,尽管[0] IS 1
我是熊猫新手,我不知道做到这一点的最佳方式。 我有我已经放置在两个不同dataframes两个文件: >> frame1.head()
Out[64]:
Date and Time Sample Unnamed: 2
0 05/18/2017 08:38:37:490 163.7 NaN
1 05/18/2017 08:39:37:490 164.5 NaN
2 05/18
我期望下面的代码正常工作,因为第一个条件如果为false,但它通过IndexError: string index out of range。我错过了什么? a = False
sample_strign = 'test'
if (a == True) & (sample_strign[7] == 's'):
print('foo')