Redian新闻
>
请教一道FAR第五章的问题
avatar
请教一道FAR第五章的问题# Accounting - 会计审计
I*A
1
老父来美探亲,忘记带够量的降压药。
美国有没有非处方降压药可以买?
多谢。
avatar
f*m
2
以前签过。 今年又想回国,可以再去CJ签吗?
avatar
F*3
3
问题很白,真是不好意思。
What I want to do is to read the input.txt file line by line and then put
into a function and write the output line by line to output.txt.
with open('/path/to/directory/input.txt','r') as f:
with open('/path/to/directory/output.txt','w') as g:
for x in f:
x = x.rstrip()
if not x: continue
print >> g, some_lib.some_function(x)
But sometimes the function won't be able to generate the output for x, and
report error. I tried to use exception handling in Python, but the program
loops over the first line instead of moving on to the next line.
with open('/path/to/directory/input.txt','r') as f:
with open('/path/to/directory/GeoIP/output.txt','w') as g:
for x in f:
x = x.rstrip()
if not x: continue
while True:
try:
print >> g, some_lib.some_function(x)
except ValueError:
print >> g, "cannot find value"
请问我哪里搞错了?不好意思我是文科的。。。
avatar
T*s
4
题目见附件,没想明白这个166 deferred interest revenue是怎么回事,谢谢
avatar
M*0
5
In general, all antihypertensive medications require prescription.
But there are lots of medications that only cost $4 for a month's supply
once you have prescriptions, much cheaper than those in China.
avatar
g*1
6
顺便问一下楼主,在墨西哥签证的风险大不大?
avatar
w*k
7
while true caused infinite loop
why do u need that line?

【在 F****3 的大作中提到】
: 问题很白,真是不好意思。
: What I want to do is to read the input.txt file line by line and then put
: into a function and write the output line by line to output.txt.
: with open('/path/to/directory/input.txt','r') as f:
: with open('/path/to/directory/output.txt','w') as g:
: for x in f:
: x = x.rstrip()
: if not x: continue
: print >> g, some_lib.some_function(x)
: But sometimes the function won't be able to generate the output for x, and

avatar
I*A
8
说的就是处方问题,而不是价格。

【在 M****0 的大作中提到】
: In general, all antihypertensive medications require prescription.
: But there are lots of medications that only cost $4 for a month's supply
: once you have prescriptions, much cheaper than those in China.

avatar
f*m
9
现在不知道,至少以前签过了。

【在 g*****1 的大作中提到】
: 顺便问一下楼主,在墨西哥签证的风险大不大?
avatar
F*3
10
太谢谢了!
我把while true干掉以后就可以了。
但是出现exception的时候好像程序直接跳过print >> g, "cannot find value",没有
写入错误信息怎么办?
with open('/path/to/directory/input.txt','r') as f:
with open('/path/to/directory/GeoIP/output.txt','w') as g:
for x in f:
x = x.rstrip()
if not x: continue
try:
print >> g, some_lib.some_function(x)
except ValueError:
print >> g, "cannot find value"
结果就是我有100个input,output文件只有50几个。。。,我希望output也有一百个,
只是有些是“cannot find value”
avatar
f*o
11
yes, see if there are any free clinics in your area use google.

【在 I**A 的大作中提到】
: 说的就是处方问题,而不是价格。
avatar
i*r
12
你确定exception 是 value error么?

【在 F****3 的大作中提到】
: 太谢谢了!
: 我把while true干掉以后就可以了。
: 但是出现exception的时候好像程序直接跳过print >> g, "cannot find value",没有
: 写入错误信息怎么办?
: with open('/path/to/directory/input.txt','r') as f:
: with open('/path/to/directory/GeoIP/output.txt','w') as g:
: for x in f:
: x = x.rstrip()
: if not x: continue
: try:

avatar
F*3
13
报错是这样的:
File "GeoIPcity.py", line 10, in
print >> g, gi.cityby_name(x)
File "build/bdist.linux-i686/egg/pygeoip/__init__.py", line 551, in org_by
_name

File "build/bdist.linux-i686/egg/pygeoip/__init__.py", line 412, in _
gethostbyname

socket.gaierror: [Errno -5] No address associated with hostname
这个是不是ValueError啊?其他的我不知道了。。。请问还有可能是什么种类的
exception我可以一个一个套。用的是geoip的包。
太谢谢了!
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。