Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit adb239d

Browse files
added programs👩‍💻👩‍💻
1 parent e9b6c0f commit adb239d

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Python program to mail merger
2+
# Names are in the file names.txt
3+
# Body of the mail is in body.txt
4+
5+
# open names.txt for reading
6+
with open("names.txt", 'r', encoding='utf-8') as names_file:
7+
8+
# open body.txt for reading
9+
with open("body.txt", 'r', encoding='utf-8') as body_file:
10+
11+
# read entire content of the body
12+
body = body_file.read()
13+
14+
# iterate over names
15+
for name in names_file:
16+
mail = "Hello " + name.strip() + "\n" + body
17+
18+
# write the mails to individual files
19+
with open(name.strip()+".txt", 'w', encoding='utf-8') as mail_file:
20+
mail_file.write(mail)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
def jpeg_res(filename):
2+
""""This function prints the resolution of the jpeg image file passed into it"""
3+
4+
# open image for reading in binary mode
5+
with open(filename,'rb') as img_file:
6+
7+
# height of image (in 2 bytes) is at 164th position
8+
img_file.seek(163)
9+
10+
# read the 2 bytes
11+
a = img_file.read(2)
12+
13+
# calculate height
14+
height = (a[0] << 8) + a[1]
15+
16+
# next 2 bytes is width
17+
a = img_file.read(2)
18+
19+
# calculate width
20+
width = (a[0] << 8) + a[1]
21+
22+
print("The resolution of the image is",width,"x",height)
23+
24+
jpeg_res("img1.jpg")

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /