Compare commits
1 Commits
57667ac8b5
...
eb74549648
Author | SHA1 | Date |
---|---|---|
Christopher Arndt | eb74549648 |
|
@ -21,3 +21,5 @@ Sie können auf diese Webseite auch unter der Kurz-URL
|
||||||
https://tinyurl.com/pythonkurs-2024-05 zugreifen.
|
https://tinyurl.com/pythonkurs-2024-05 zugreifen.
|
||||||
|
|
||||||
![QR Code für Kurz-URL](qrcode-kursmaterialien.png)
|
![QR Code für Kurz-URL](qrcode-kursmaterialien.png)
|
||||||
|
|
||||||
|
**Viel Spaß beim Kurs!**
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
import sys
|
|
||||||
|
|
||||||
filename = sys.argv[1]
|
|
||||||
|
|
||||||
with open(filename, "rb") as fileobj:
|
|
||||||
data = fileobj.read()
|
|
||||||
|
|
||||||
num_bytes = len(data)
|
|
||||||
|
|
||||||
print(f"The file contents are {num_bytes} long.")
|
|
|
@ -1,14 +0,0 @@
|
||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
import sys
|
|
||||||
|
|
||||||
filename = sys.argv[1]
|
|
||||||
|
|
||||||
with open(filename, "r") as fileobj:
|
|
||||||
data = fileobj.read()
|
|
||||||
|
|
||||||
max_linelength = 0
|
|
||||||
for line in data.splitlines():
|
|
||||||
max_linelength = max(max_linelength, len(line))
|
|
||||||
|
|
||||||
print(f"The longest line has a length of {max_linelength}.")
|
|
|
@ -1,16 +0,0 @@
|
||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
import sys
|
|
||||||
|
|
||||||
filename = sys.argv[1]
|
|
||||||
|
|
||||||
with open(filename, "r") as fileobj:
|
|
||||||
max_linelength = 0
|
|
||||||
longest_line = -1
|
|
||||||
|
|
||||||
for i, line in enumerate(data):
|
|
||||||
if len(line) > max_linelength:
|
|
||||||
max_linelength = len(line)
|
|
||||||
longest_line = i + 1
|
|
||||||
|
|
||||||
print(f"The longest line is line {longest_line} with a length of {max_linelength}.")
|
|
|
@ -1,24 +0,0 @@
|
||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
import sys
|
|
||||||
|
|
||||||
filename = sys.argv[1]
|
|
||||||
|
|
||||||
data = {}
|
|
||||||
|
|
||||||
with open(filename, "r") as fileobj:
|
|
||||||
for i, line in enumerate(data):
|
|
||||||
line = line.strip() # remove whitespace from start/end of line
|
|
||||||
|
|
||||||
if line.startswith('#'):
|
|
||||||
# ignore comment lines
|
|
||||||
continue
|
|
||||||
|
|
||||||
name, raw_data = line.split(":", 1) # split line at first colon
|
|
||||||
items = raw_data.split(",") # split raw data at commas
|
|
||||||
|
|
||||||
data[name.strip()] = items
|
|
||||||
|
|
||||||
|
|
||||||
for key in data:
|
|
||||||
print(key, data[key])
|
|
Loading…
Reference in New Issue