File tree Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Original file line number Diff line number Diff line change
1
+ from PIL import Image
2
+
3
+ file_name = "MonaLisa.jpg"
4
+ img = Image .open (file_name )
5
+ img .show ()
6
+
7
+ colors = img .getpixel ((320 , 240 ))
8
+
9
+ print (colors )
Original file line number Diff line number Diff line change
1
+ import re
2
+ import pyperclip
3
+
4
+ # Create phone regex.
5
+ phone = re .compile (r'''(
6
+ (\d{3}|\(\d{3}\))?
7
+ (\s|-|\.)?
8
+ (\d{3})
9
+ (\s|-|\.)
10
+ (\d{4})
11
+ (\s*(exr|x|ext.)\s*(\d{2, 5}))?
12
+ )''' , re .VERBOSE )
13
+
14
+ # Create email regex.
15
+ email = re .compile (r'''(
16
+ [a-zA-Z0-9._%+-]+
17
+ @
18
+ [a-zA-Z0-9.-]+
19
+ (\.[a-zA-Z]{2,4})
20
+ )''' , re .VERBOSE )
21
+
22
+ # Find matches in clipboard text.
23
+ text = str (pyperclip .paste ())
24
+
25
+ matches = []
26
+ for groups in phone .findall (text ):
27
+ phoneNum = '-' .join ([groups [1 ], groups [3 ], groups [5 ]])
28
+ if groups [8 ] != '' :
29
+ phoneNum += ' x' + groups [8 ]
30
+ matches .append (phoneNum )
31
+ for groups in email .findall (text ):
32
+ matches .append (groups [0 ])
33
+
34
+ # Copy results to the clipboard.
35
+ if len (matches ) > 0 :
36
+ pyperclip .copy ('\n ' .join (matches ))
37
+ print ('Copied to clipboard:' )
38
+ print ('\n ' .join (matches ))
39
+ else :
40
+ print ('No phone numbers or email addresses found.' )
You can’t perform that action at this time.
0 commit comments