-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
this is some test [Animaslsd] sdtri |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
b = 5 | ||
a = 2 | ||
assert b < a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
""" | ||
Content of "log.txt": | ||
10.1.2.1 - car [01/Mar/2022:13:05:05 +0900] "GET /python HTTP/1.0" 200 2222 | ||
10.1.1.9 - bike [01/Mar/2022:13:05:10 +0900] "GET /python HTTP/1.0" 200 2222 | ||
Expected output: | ||
01/Mar/2022:13:05:05 +0900 | ||
01/Mar/2022:13:05:10 +0900 | ||
""" | ||
import re | ||
|
||
def parse1(): | ||
for line in open("log.txt"): | ||
print(line.split("[")[1].split("]")[0]) | ||
assert True | ||
|
||
def parse2(): | ||
for line in open("log.txt", "r"): | ||
print(line.split()[3].strip("[]")) | ||
assert False | ||
|
||
def parse3(): | ||
for line in open("log.txt", "r"): | ||
print(" ".join(line.split("[" or "]")[3:5])) | ||
assert True | ||
|
||
print('Hello World') | ||
parse3() | ||
|
||
|
||
if __name__ == "__main__": | ||
parse1() | ||
parse3() |