小编ahh*_*wer的帖子

将由"\ r \n"分隔的字符串拆分为行列表?

我正在从子进程模块的通信方法中读取一些数据.它以"\ r \n"分隔的大字符串形式出现.我想把它拆分成一个行列表.这是如何在python中执行的?

python string

23
推荐指数
1
解决办法
2万
查看次数

与python整数比较真的很尴尬(看似简单)的bug

我有下面的代码,它没有像我期望的那样工作......

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.为什么会这样?

编辑:我也试过这个!=而不是'不是',得到了相同的结果.

python identity equality

0
推荐指数
1
解决办法
1174
查看次数

标签 统计

python ×2

equality ×1

identity ×1

string ×1