【发布时间】:2016-02-09 01:28:58
【问题描述】:
文件内容:
aditya@aditya-virtual-machine:~/urlcat$ cat http_resp
telnet 10.192.67.40 80
Trying 10.192.67.40...
Connected to 10.192.67.40.
Escape character is '^]'.
GET /same_domain HTTP/1.1
Host: www.google.com
HTTP/1.1 200 OK
Date: Tue, 09 Feb 2016 00:25:36 GMT
Server: Apache/2.4.7 (Ubuntu)
Last-Modified: Fri, 08 Jan 2016 20:10:52 GMT
ETag: "81-528d82f2644f1"
Accept-Ranges: bytes
Content-Length: 129
我的代码:
f1 = open('http_resp')
read=f1.read()
for line in read:
# line=line.rstrip()
line=line.strip()
if not '.com' in line:
continue
print line
当if not逻辑被移除时,输出是这样的:
它只逐行打印单个字符。
t
e
l
n
e
t
1
0
.
1
9
2
.
6
7
.
4
0
8
0
T
r
y
i
n
g
我不想逐个字符打印。
【问题讨论】:
标签: python python-2.7 for-loop python-2.x