我正在从子进程模块的通信方法中读取一些数据.它以"\ r \n"分隔的大字符串形式出现.我想把它拆分成一个行列表.这是如何在python中执行的?
我有下面的代码,它没有像我期望的那样工作......
current_frame = 15 # just for showcasing purposes
g_ch = 7
if (current_frame != int(row[0])) and (int(row[1]) != g_ch):
current_frame = int(row[0])
print "curious================================="
print current_frame
print row
print current_frame, " != ", int(row[0]), ", ", current_frame != int(row[0])
print "========================================"
Run Code Online (Sandbox Code Playgroud)
打印任何特定情况:
curious=================================
15
['15', '1', 'more data'] 15 != 15 , False
========================================
Run Code Online (Sandbox Code Playgroud)
这显然永远不会输入if语句,因为等式显示为false.为什么会这样?
编辑:我也试过这个!=而不是'不是',得到了相同的结果.