由买买提看人间百态

topics

全部话题 - 话题: readlines
首页 上页 1 2 3 4 5 6 下页 末页 (共6页)
m********0
发帖数: 2717
1
IB没有返回options symbol list的函数,需要自己生成。
给你一个我以前用过的script,我自己从bloomberg下载的list,然后下载的options数
据,
基于IBPY, 另外IB数据很差,如果只是为了计算max pain,到处都有,没必要自己闭门造车。
#! /usr/bin/env python
# -*- coding: utf-8 -*-
from ib.ext.Contract import Contract
from ib.opt import ibConnection, message
from time import sleep
from datetime import date
# print all messages from TWS
def watcher(msg):
print msg
# show Bid and Ask quotes
def my_BidAsk(msg):
if msg.field == 1:
print '%s:%s: bid: %s' % (contractTuple[0],
... 阅读全帖
H******e
发帖数: 4682
2
希望static node fromArray(int[] a) {...}中的head或者tail只用到一个, 应该如何
update codes? Expect working codes in visual studio with only head or tail,
which mean eliminate the head or tail. Just 1 variable, no constructor. :)
hint:
You do not need double-linked list. Just think, why do we have head and tail
variables. We do not do anything with head except initial assignment.
class node
{
public int value;
public node next = null;
static node fromArray(int[] a)
{
... 阅读全帖
x**********g
发帖数: 82
3
来自主题: EB23版 - 写程序处理perm 数据
Python program
# Authored by xiaofeixiang
# Copyright reserved to EBC23
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or (at
# your option) any later version.
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTI... 阅读全帖
c**n
发帖数: 312
4
改进版:
from time import sleep
import urllib2
import re
import sys
file = open(sys.argv[1])
cases = file.readlines()
typeP = re.compile('Your Current Case Status for Form (\w+)')
statusP = re.compile('Your Case Status:
([\w\s/]*?)')
dateP = re.compile('(January|February|March|April|May|June|July|August|
September|Octobert|November|December) \d{1,2}, \\
d{4}')
for caseId in cases:
caseId = caseId.strip()
req = urllib2.Request("https://egov.uscis.gov/cris/Dashboard/CaseStatus.
do?app... 阅读全帖
m***f
发帖数: 732
5
来自主题: LosAngeles版 - 写了个 SAC的抓deal code (转载)
【 以下文字转载自 Outdoors 讨论区 】
发信人: motif (魔地佛), 信区: Outdoors
标 题: 写了个 SAC的抓deal code
发信站: BBS 未名空间站 (Wed Nov 3 17:01:39 2010, 美东)
抓到你想要的deal自动给你发email或短消息,有兴趣的下去改了用。直接拷贝下面这
段code修改后存为sac.py,然后运行python sac.py即可。在python 2.7下测试通过。
#!/usr/bin/python
import re
import urllib
import smtplib
import time
from email.mime.text import MIMEText
target=[['trekking', 'poles'],['Napali', 'Backpack'],['north', 'face'],['
oakley','battalion']] #The items you want to monitor, in every set of [] AND
logical will be us... 阅读全帖
q****x
发帖数: 7404
6
来自主题: SanFrancisco版 - Python大牛请进 (转载)
【 以下文字转载自 JobHunting 讨论区 】
发信人: quantx (X矿工), 信区: JobHunting
标 题: Python大牛请进
发信站: BBS 未名空间站 (Sun Sep 23 04:11:34 2012, 美东)
这个yield到底有啥好处?这里的例子怎么省内存了?readlines不还是要读入整个文件
吗?
http://stackoverflow.com/questions/7883962/where-to-use-yield-i
我的理解:
def func_0(input_list):
return [f(i) for i in input_list]
def func_1(input_list):
for i in input_list:
yield f(i)
这两个区别在于,func_0把所有的f(i)算好,返回。func_1创建一个对象,包含input_
list,函数f,迭代子iter。遍历这个对象时,动态计算f(i)。这样看上去只是lazy
evaluation,并没有省内存啊。
g*****g
发帖数: 34805
7
Java用BufferedReader.readLine, regex,或者String.indexOf找都行。
c*********l
发帖数: 3438
8
【 以下文字转载自 JobHunting 讨论区 】
发信人: will5 (绽放), 信区: JobHunting
标 题: FB临门一脚挂了,那种郁闷悔恨的感觉.
发信站: BBS 未名空间站 (Thu Oct 17 17:55:34 2013, 美东)
上次onsite,4轮,自己感觉很好.
HR回信也说: went well so far but still need last code question interview to
end the process
要安排电话面试
结果我说:电面不好,我要求onsite,今天上午就onsite了.
结果, 一看是一个严肃的老印,基本听不懂其在说什么
就一道题:
实现 int Read(int Size, char * buffer) using int Read4(char * buffer)
这题思路很简单的,我当时给了2种方法结果在他的引导上走上了一条不归路,第一次实
现有bug, 没考虑buffer里面留下的部分....汗 ...各种改...(这题原来有过类似的
readLine, 但是自己觉得应该简单没有动手仔细写过, ... 阅读全帖
o**********e
发帖数: 18403
9
【 以下文字转载自 Dreamer 讨论区 】
发信人: Dreamer (不要问我从哪里来), 信区: Dreamer
标 题: 面完fb,结果已经出来了,share下被拒的原因(请转jobhunting版
发信站: BBS 未名空间站 (Tue Nov 18 20:46:44 2014, 美东)
考了下古,发现这位哥们的转贴,基本可以确认是一个人,基本可以确定这个是我被拒
的原因
同样迟到了大概5分钟,闲扯了十分钟左右,然后read4,确实很简单,但是给的题目非
常不清楚,所以完全没有考虑buffer里面留下的部分,中间我问了除了输出int,需不需
要考虑读出的字符放在哪里,被他含混过去了。自己没做过底层的东西,竟然也没有看
到这个帖子,细节基本一致,因为题目很简单,所以35分钟内完成,全程毫无任何提示
,所有问他的问题基本上都回答得非常模糊,非常有误导性。之后让问fb问题,自己回
答了六周的ramp 什么着,我明明没问。。。最后拍照
我比下面这位哥们唯一好点的地方,我记下了这个人的名字的大致发音,自己查了下
linkedin, 应该是R--it---u---raj Kir---... 阅读全帖
o**********e
发帖数: 18403
10
【 以下文字转载自 SanFrancisco 讨论区 】
发信人: onetiemyshoe (onetiemyshoe), 信区: SanFrancisco
标 题: 面完fb,结果已经出来了,share下被拒的原因(请转jobhunting版 (转载)
发信站: BBS 未名空间站 (Wed Nov 19 21:05:36 2014, 美东)
发信人: Dreamer (不要问我从哪里来), 信区: Dreamer
标 题: 面完fb,结果已经出来了,share下被拒的原因(请转jobhunting版
发信站: BBS 未名空间站 (Tue Nov 18 20:46:44 2014, 美东)
考了下古,发现这位哥们的转贴,基本可以确认是一个人,基本可以确定这个是我被拒
的原因
同样迟到了大概5分钟,闲扯了十分钟左右,然后read4,确实很简单,但是给的题目非
常不清楚,所以完全没有考虑buffer里面留下的部分,中间我问了除了输出int,需不需
要考虑读出的字符放在哪里,被他含混过去了。自己没做过底层的东西,竟然也没有看
到这个帖子,细节基本一致,因为题目很简单,所以35分钟内... 阅读全帖
m***f
发帖数: 732
11
来自主题: Outdoors版 - 写了个 SAC的抓deal code
抓到你想要的deal自动给你发email或短消息,有兴趣的下去改了用。直接拷贝下面这
段code修改后存为sac.py,然后运行python sac.py即可。在python 2.7下测试通过。
#!/usr/bin/python
import re
import urllib
import smtplib
import time
from email.mime.text import MIMEText
target=[['trekking', 'poles'],['Napali', 'Backpack'],['north', 'face'],['
oakley','battalion']] #The items you want to monitor, in every set of [] AND
logical will be used to match a specific item
discount_threshold=50 #threshold of percentage to trigger event
check_interval=60 #the interval to ... 阅读全帖
t********e
发帖数: 32
12
来自主题: Running版 - 照片来了~~~
以前pen用python写了个小程序抓图, 谁要是改改应该就能用了把
#!/usr/bin/env python
import cgi
import cgitb; cgitb.enable() # for troubleshooting
from datetime import datetime
import sys
import os
import re
import getpass
import urllib
print "Content-type: text/html"
print
print """


"""
form = cgi.FieldStorage()
event = 00
bib = 9079
#event = int(form["event"].value)
#bib = int(form["bib"].value)
pics = []

base_dir = "/Users/changyao/Desktop/brightroom"
#base_dir = "/tmp"
os.chdir(base_dir)
logfile = "l... 阅读全帖
r*******1
发帖数: 4394
13
来自主题: Ski版 - 想买snowboard,请教大虾们
option motive 貌似可以, readline 是all montain directional board
125lb 大概买152-154cm
H******e
发帖数: 4682
14
希望static node fromArray(int[] a) {...}中的head或者tail只用到一个, 应该如何
update codes? Expect working codes in visual studio with only head or tail,
which mean eliminate the head or tail. :)
hint:
You do not need double-linked list. Just think, why do we have head and tail
variables. We do not do anything with head except initial assignment.
class node
{
public int value;
public node next = null;
static node fromArray(int[] a)
{
if (a.Count() == 0) return... 阅读全帖
H******e
发帖数: 4682
15
I was told below:
So, you still have 2 variables. Even more, you have 3 variables.
You do not need double-linked list. Just think, why do we have head and tail
variables. We do not do anything with head except initial assignment.
==================================
Below are the updated codes for the solution using doubly linked list:
class node
{
public int value;
public node next = null;
public node prev = null;
static node fromArray(int[] a)
{
... 阅读全帖
T*********r
发帖数: 11175
16
来自主题: Apple版 - fink里的gnuplot怎么没了
最后是直接装了
./configure --with-readline=bsd --x-include=/usr/include/X11 --x-libraries=/
usr/X11/lib
and then use make and sudo make install.
http://chuyandmac.blogspot.com/2009/09/gnuplot-in-snow-leopard.html
S**I
发帖数: 15689
17
直接从gnuplot的源文件编译安装,有X11就行了,不是非得用octave不可:
./configure --with-readline=bsd --x-include=/usr/include/X11 --x-libraries=/
usr/X11/lib
make
sudo make install

set
了!
d******8
发帖数: 2191
18
来自主题: BuildingWeb版 - WebSocket问题
第一次学习JavaScript WebSocket做了个小实验,用它去连接本地C# Server,结果
server上显示连接成功了,但JS却一直处于正在连接状态。下面的代码解释部分代表输
出(未输出)的状态。如果在Javascript后加上cnt.send('abc'),错误信息为:
InvalidStateError: Failed to execute 'send' on 'WebSocket': Still in
CONNECTING state.。等很久都没有timeout error,说明Javascript一直在连接Server
。但是Server已经显示连接成功了呀。求牛人指点!
Javascript:
var cnt=new WebSocket("ws://localhost:8001");
cnt.onopen=function(){console.log('connection setup!');};// not shown
cnt.onmessage=function(msg){console.log(msg);}; // not shown
cnt.onerr... 阅读全帖
l********0
发帖数: 283
19
来自主题: Database版 - 这两天mysql总是出现一个问题
问题是这样的:
Linux: CentOS release 5.2 (Final)
MySQL:Ver 14.12 Distrib 5.0.22, for redhat-linux-gnu (x86_64) using readline
5.0
这几天总是出现这个问题:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var
/lib/mysql/mysql.sock' (2)
在Linux的shell里面建立mysql连接时,总是这样
已经找了Google,试了一些方法,但是都无效
大家有没有遇到类似问题?如何解决的?谢谢
l********0
发帖数: 283
20
来自主题: Database版 - 这两天mysql总是出现一个问题
我终于查出原因了
原来是,硬盘满了!导致不能写sock等文件!

readline
var
A*******n
发帖数: 625
21
var lineCount = File.ReadAllLines(@"C:\file.txt").Length;
or
var lineCount = 0;
using (var reader = File.OpenText(@"C:\file.txt"))
{
while (reader.ReadLine() != null)
{
lineCount++;
}
}
p*******p
发帖数: 13670
22
i see, 那么我现在的问题是整个字符串的每个字符都要移动3袼,是不是这样就可以了
string tmp=Console.Readline();
for(i=0;i {
tmp[i]=(char)(tmp[i]+3);
}
3x
d*****n
发帖数: 2132
23
来自主题: DotNet版 - .net 4.0 parallel computing 的意义
thanks for reply.
If it works for you, then there must be some disconnection somewhere between
you and me.
I attached the sample below and did the test just now on a 6 core, 8 gb
machine, it just reconfirmed my previous observation: all cpu runs at 100%
while the program is running.
Can you try on your server and see if you run into the same thing?
Thanks!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
... 阅读全帖
d******8
发帖数: 2191
24
来自主题: DotNet版 - WebSocket问题 (转载)
【 以下文字转载自 BuildingWeb 讨论区 】
发信人: dd322508 (银河), 信区: BuildingWeb
标 题: WebSocket问题
发信站: BBS 未名空间站 (Sun Aug 24 15:48:23 2014, 美东)
第一次学习JavaScript WebSocket做了个小实验,用它去连接本地C# Server,结果
server上显示连接成功了,但JS却一直处于正在连接状态。下面的代码解释部分代表输
出(未输出)的状态。如果在Javascript后加上cnt.send('abc'),错误信息为:
InvalidStateError: Failed to execute 'send' on 'WebSocket': Still in
CONNECTING state.。等很久都没有timeout error,说明Javascript一直在连接Server
。但是Server已经显示连接成功了呀。求牛人指点!
Javascript:
var cnt=new WebSocket("ws://localhost:8001");
cnt.onopen=f... 阅读全帖
n******7
发帖数: 12463
25
是的 readline不work
n******7
发帖数: 12463
26
是的 readline不work
i*****e
发帖数: 2810
27
Well. I guess it should be ok to use readLine(). How about try this code?
Runtime r = Runtime.getRuntime()
try{
Process p = r.exec("ps -l");
InputStream in = p.getInputStream();
int ch;
while((ch = in.read()) != -1) System.out.print((char)ch);

in.close();
try {
p.waitFor();
}catch(InterruptedException e) { }
}catch(Exception e){}
xt
发帖数: 17532
28

This is because DataInputStream is used to read in binary data,
not text data. You need to do sth like this:
//suppose you input 1 number a time, otherwise please use
//StringTokenizer after reading in the line string.
float x = 0.0;
String line = null;
try {
line = System.in.readLine();
}catch (IOException e) {
}
if (line!=null && line.length>0) {
try {
x = Float.parsefloat(line);
} catch (NumberFormatException e) {
}
}
w*******u
发帖数: 15
29
来自主题: Java版 - 怎么从键盘输入整数或float?
我发现有个网友写过,但不能用.本人刚刚接触java,谢谢大家帮忙!!!!
float x = 0.0;
String line = null;
try {
line = System.in.readLine();
}catch (IOException e)//i guess here " e" should be"exc",but still doesn't
work
{
}
if (line!=null && line.length>0) {
try {
x = Float.parsefloat(line);
} catch (NumberFormatException e)// i guess here " e" should be"exc"
{
}
f**t
发帖数: 27
30
来自主题: Java版 - 怎么从键盘输入整数或float?

}
~~~~~~~~~~~~~~~~~~~~~
readLine() is not InputStream member function, belongs BufferedReader()
order you can use read()
doesn't
st
发帖数: 1685
31
来自主题: Java版 - 请教一个问题,thanks!
below should work. I think the output is string instead of float. I seem
to have said that before.
String temp=datastream.readLine();
float result=Float.valueOf(temp);
M*****n
发帖数: 2301
32
来自主题: Java版 - 请教一个问题,thanks!
好像还是不行。debug执行到String temp = cs2result.readLine();
的时候就停了
是不是因为读output的时候那个process还没执行完毕的原因?
那个process是个大计算,怎么能让java等那个process terminate
以后在去读output呢?
process.waitFor(); 好像也不行啊
多谢!
f********f
发帖数: 475
33
来自主题: Java版 - 请教一个问题,thanks!
建议你用temp = cs2result.read()而不是readLine()试试。
c*******t
发帖数: 32
34
来自主题: Java版 - [转载] smtp server in java?
【 以下文字转载自 Programming 讨论区 】
【 原文由 coldstart 所发表 】
My program:
Using thread for each connention.
Using BufferedInputStream and BufferedReader to get message from client.
Using readLine() to get each line from client.
Problem:
When there are attachments coming in. SMTP server receive them very slowly.
If I increase the buffer size, that will be fine for one email with big
attachment.
But don't work on a lot of email coming in at once. The error is Outofmemory.
What shall I do to increase the speed
c**g
发帖数: 274
35
The way java does this is kind of complicated (actually
it is similar to c++ way with std io), you open a file
with an FileInputStream, then wrap the FileInputStream with
InputStreamReader to become a Reader, then wrap the
InputStreamReader to become a BufferedReader, then
use readLine(), finally parse out. Kao.
g**********y
发帖数: 14569
36
来自主题: Java版 - Help on file locking
Java seems have not so perfect FileLock mechanism --
1. lock() will physically lock the file in that OS. The second call lock()
will cause Exception thrown. Ideally, if the second call comes from the same
thread, it should be fine. However, JVM failed here.
I write a piece of code:
RandomAccessFile raf = new RandomAccessFile("test.txt");
FileChannel fc = raf.getChannel();
fc.lock();
System.out.println(raf.readLine()); // (1)
readFile(); // (2)
fc.release();
private
o***g
发帖数: 2784
37
来自主题: Java版 - 请教问题,怎么确定空行!
didn't you use BufferedReader?
there is a method called readLine();
g*****g
发帖数: 34805
38
来自主题: Java版 - 请教问题,怎么确定空行!
BufferedReader.readLine().trim().equals("")
y********o
发帖数: 2565
39
I just saw it and tried it with the 1.6-rc version, maybe this is what you
want.
http://java.sun.com/docs/books/tutorial/essential/io/cl.html
import java.io.Console;
import java.util.Arrays;
import java.io.IOException;
public class Password {

public static void main (String args[]) throws IOException {
Console c = System.console();
if (c == null) {
System.err.println("No console.");
System.exit(1);
}
String login = c.readLine("Enter
g*****g
发帖数: 34805
40
来自主题: Java版 - pipe & filter 问题
while((line=reader.readline())!=null) {
if(line.matches(pattern) {
list.add(line);
}
}
Collections.sort(list);
m******t
发帖数: 2416
41
来自主题: Java版 - pipe & filter 问题
Something like this I guess:
SortedSet set = new TreeSet();
while((line=reader.readline())!=null) {
if(line.matches(pattern) {
set.add(line);
}
}
q*c
发帖数: 9453
42
自从改用java + linux 实在烦恼啊。最近两天一横程序也写不了,
就为了一个简单的问题:
tomcat 5.x + JSP. 要干的事情实在简单, 用户 http POST 上来
一个简单的 xml, parse 一下就好。
但是我死活无法从 jsp 得到 request body.
request:
http1.1 POST
d**[email protected]
就是这样的简单。JSP 的request getParameter(String) 只能处理
plain text pair. 如果我使用 BufferedReader br = request.getReader(),
br.readLine() 就只能返回 null, io = request.getInputStream();
io.read() 也都是 null. google 了两天,据说是tomcat 提前八stream
parse le, 由于只能parse 一次,因此后续的read 都不行了。必须使用
getXXXXX() 莱得到参数, 但是就是没有一个method : ge
g*****g
发帖数: 34805
43
sure, how about this?
while((str=bufferedReader.readLine())!=null) {
String[] tokens = str.split("\\s");
}
I*******e
发帖数: 1879
44
☆─────────────────────────────────────☆
ganyaz (dk) 于 (Sat Jul 14 13:57:40 2007) 提到:
I am a beginner.
Is there any "readLine()" or similar methods for the reading of binary files
?
I mean to read binary and interprete them as floating point binary data.
Thanks!
☆─────────────────────────────────────☆
goodbug (好虫) 于 (Sat Jul 14 14:26:31 2007) 提到:
something like
FileInputStream fileinputstream = new FileInputStream(file);
int numberBytes = fileinputstream.available();
h**j
发帖数: 2033
45
这程序不对吧 readLine的返回都没保存
你想要啥样的效果
如果连cmd窗口都要跳出来 还是用swt/jni
如果不想输出混乱 就开个buffer保存inputstream的输出 最后统一打印

一句
f*******y
发帖数: 988
46
来自主题: Java版 - JAVA文本文件读写问题
如果一个文件是这样
AS BD CA 1.1
DS FD EA 3.4
(下略)
每行中间是tab分开的; 怎么样一个一个读出每个String和double ?
C++里面直接用《就可以了,java我只找到一个readline()
有什么简单的method,比如readDouble, readInt, readString这类的么?
m******t
发帖数: 2416
47
来自主题: Java版 - JAVA文本文件读写问题
LZ could also try read one line a time (with readLine()), and use String.
split to split the line into parts.
t*g
发帖数: 1758
48
来自主题: Java版 - 请教读取中文文件的问题
中文文件里面有4个字"萨尔加多",utf-8 encoding.
下面是code
public static void main(String[] args) {

String queries="c:\\temp\\qauto.txt";
try{
BufferedReader in = new BufferedReader(new InputStreamReader(new
FileInputStream(queries),"UTF-8"));
String str=in.readLine();
System.out.println(str+"length"+str.length());
}catch(Exception e){
e.printStackTrace();
}
}
打印出来是5个字符。为什么?好像在第三个和第四个中间加了一个。eclipse的console
没法给我显示中文输出。谢谢!
s*******9
发帖数: 1
49
public class GetInputFromKeyboard1 {
public static void main(String[] args){
BufferedReader dataIn = new BufferedReader(new InputStreamReader(
System.in));
BufferedReader is = new BufferedReader(new InputStreamReader(System.
in));
int number ;
System.out.println("How Many Names You Wish To Enter:");
String name = "";
String strIn = "";
try{
strIn = is.readLine();
}catch(IOException e){
System.out.println(
首页 上页 1 2 3 4 5 6 下页 末页 (共6页)