· 7 years ago · Sep 10, 2018, 09:06 AM
1import os
2o = open("vids.html","w")
3o.write("""
4<!DOCTYPE html>
5<html>
6<head>
7<title>Some videos</title>
8</head>
9
10<body>
11Some good videos and other videos I just happen to have saved for whatever reason.
12<p/>
13I'm sorry if I violate any copyrights. If you own one of these videos and care that it's here then just tell me in an email and I'll take it down. My email address is inhahe at gmail.com.
14
15""")
16for fn in os.listdir('favoritevideos'):
17 if fn[-3:] != "jpg":
18# o.write(f'<div style="display: inline-block"><a href="{fn}"><img src="{fn}.jpg"/></a><br/>{fn}</div>')
19 o.write(f'<a href="{fn}"><img src="{fn}.jpg"/></a><br/>{fn}<p/>')
20
21o.write('</body></html>')
22
23
24-----------------------
25
26Error:
27
28Traceback (most recent call last):
29 File "makevidpage.py", line 19, in <module>
30 o.write(f'<a href="{fn}"><img src="{fn}.jpg"/></a><br/>{fn}<p/>')
31 File "c:\Python36-32\lib\encodings\cp1252.py", line 19, in encode
32 return codecs.charmap_encode(input,self.errors,encoding_table)[0]
33UnicodeEncodeError: 'charmap' codec can't encode characters in position 45-47: character maps to <undefined>