如果我执行以下操作: import subprocess from cStringIO import StringIO subprocess.Popen(['grep','f'],stdout=subprocess.PIPE,stdin=StringIO('one\ntwo\nthree\nfour\nfive\nsix\n')).communicate()[0] 我得到: Traceback (most recent call last): File "<stdin>", line 1, in ? File "/build/toolchain/mac32/python-2.4.3/lib/python2.4/subprocess.py", line 533, in __init__ (p2cread, p2cwrite, File "/build/toolchain/mac32/python-2.4.3/lib/python2.4/subprocess.py", line 830, in _get_handles p2cread = stdin.fileno() AttributeError: 'cStringIO.StringI' object has no attribute 'fileno' 显然,cStringIO.StringIO对象没有足够接近库中的子程序来适应subprocess.Popen。我该如何解决?
目前,我在声明中正在执行一个非常基本的OrderBy。 SELECT * FROM tablename WHERE visible=1 ORDER BY position ASC, id DESC 问题是“位置”的NULL条目被视为0。因此,所有位置为NULL的条目都出现在具有1,2,3,4的条目之前。例如: NULL, NULL, NULL, 1, 2, 3, 4 有没有一种方法可以实现以下排序: 1, 2, 3, 4, NULL, NULL, NULL.