Questions tagged «output»

在某些输入上调用程序的外部可观察的结果

2
如何使用python numpy.savetxt将字符串和浮点数写入ASCII文件?
我有一组包含字符串和浮点数的列表,例如: import numpy as num NAMES = num.array(['NAME_1', 'NAME_2', 'NAME_3']) FLOATS = num.array([ 0.5 , 0.2 , 0.3 ]) DAT = num.column_stack((NAMES, FLOATS)) 我想将这两个列表堆叠在一起,然后将它们以列的形式写入文本文件;因此,我想使用numpy.savetxt(如果可能)来执行此操作。 num.savetxt('test.txt', DAT, delimiter=" ") 当我这样做时,出现以下错误: >>> num.savetxt('test.txt', DAT, delimiter=" ") Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Library/Python/2.7/site-packages/numpy-1.8.0.dev_9597b1f_20120920-py2.7-macosx-10.8-x86_64.egg/numpy/lib/npyio.py", line 1047, in …
70 python  list  numpy  output 

8
如何使用Python从URL读取CSV文件?
当我卷曲到API调用链接时http://example.com/passkey=wedsmdjsjmdd curl 'http://example.com/passkey=wedsmdjsjmdd' 我以csv文件格式获取员工输出数据,例如: "Steve","421","0","421","2","","","","","","","","","421","0","421","2" 如何使用python解析。 我试过了: import csv cr = csv.reader(open('http://example.com/passkey=wedsmdjsjmdd',"rb")) for row in cr: print row 但它不起作用,我出现了一个错误 http://example.com/passkey=wedsmdjsjmdd No such file or directory: 谢谢!
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.