diff --git a/LuHR_showcode/__pycache__/x0001.cpython-35.pyc b/LuHR_showcode/__pycache__/x0001.cpython-35.pyc new file mode 100644 index 00000000..8b03be9e Binary files /dev/null and b/LuHR_showcode/__pycache__/x0001.cpython-35.pyc differ diff --git a/LuHR_showcode/__pycache__/x0004.cpython-35.pyc b/LuHR_showcode/__pycache__/x0004.cpython-35.pyc new file mode 100644 index 00000000..1c47eb38 Binary files /dev/null and b/LuHR_showcode/__pycache__/x0004.cpython-35.pyc differ diff --git a/LuHR_showcode/__pycache__/x0011.cpython-35.pyc b/LuHR_showcode/__pycache__/x0011.cpython-35.pyc new file mode 100644 index 00000000..b4ecee15 Binary files /dev/null and b/LuHR_showcode/__pycache__/x0011.cpython-35.pyc differ diff --git a/LuHR_showcode/backpic.jpg b/LuHR_showcode/backpic.jpg new file mode 100644 index 00000000..36578a18 Binary files /dev/null and b/LuHR_showcode/backpic.jpg differ diff --git a/LuHR_showcode/base.html b/LuHR_showcode/base.html new file mode 100644 index 00000000..7df62a0b --- /dev/null +++ b/LuHR_showcode/base.html @@ -0,0 +1,43 @@ + + + + + + + + + + + + + First bootstrap page + + + + +
+
+
+

+ input here: + +
+
+
+ + + + +> \ No newline at end of file diff --git a/LuHR_showcode/filtered_words.txt b/LuHR_showcode/filtered_words.txt new file mode 100644 index 00000000..a5d1d90a --- /dev/null +++ b/LuHR_showcode/filtered_words.txt @@ -0,0 +1,11 @@ +北京 +程序员 +公务员 +领导 +牛比 +牛逼 +你娘 +你妈 +love +sex +jiangge \ No newline at end of file diff --git a/LuHR_showcode/input.txt b/LuHR_showcode/input.txt new file mode 100644 index 00000000..06fe5a5d --- /dev/null +++ b/LuHR_showcode/input.txt @@ -0,0 +1,3 @@ +锘###棰樼洰瑕佹眰 浠讳竴涓嫳鏂囩殑绾枃鏈枃浠讹紝缁熻鍏朵腑鐨勫崟璇嶅嚭鐜扮殑涓暟銆 + +###Topic request in a English plain text file, you must count the number of every word that appear in it. \ No newline at end of file diff --git a/LuHR_showcode/result.jpg b/LuHR_showcode/result.jpg new file mode 100644 index 00000000..a53c52c0 Binary files /dev/null and b/LuHR_showcode/result.jpg differ diff --git a/LuHR_showcode/sbym_picture/072a6ff0f736afc3fd8c5344b219ebc4b64512f7.jpg b/LuHR_showcode/sbym_picture/072a6ff0f736afc3fd8c5344b219ebc4b64512f7.jpg new file mode 100644 index 00000000..c5bf83d6 Binary files /dev/null and b/LuHR_showcode/sbym_picture/072a6ff0f736afc3fd8c5344b219ebc4b64512f7.jpg differ diff --git a/LuHR_showcode/sbym_picture/0a910cd5ad6eddc43200d8da38dbb6fd53663394.jpg b/LuHR_showcode/sbym_picture/0a910cd5ad6eddc43200d8da38dbb6fd53663394.jpg new file mode 100644 index 00000000..95720bce Binary files /dev/null and b/LuHR_showcode/sbym_picture/0a910cd5ad6eddc43200d8da38dbb6fd53663394.jpg differ diff --git a/LuHR_showcode/sbym_picture/0d46ca54564e9258fe06e9cf9d82d158ccbf4e41.jpg b/LuHR_showcode/sbym_picture/0d46ca54564e9258fe06e9cf9d82d158ccbf4e41.jpg new file mode 100644 index 00000000..8ae34b78 Binary files /dev/null and b/LuHR_showcode/sbym_picture/0d46ca54564e9258fe06e9cf9d82d158ccbf4e41.jpg differ diff --git a/LuHR_showcode/sbym_picture/1e29460fd9f9d72abb1a7c3cd52a2834349bbb7e.jpg b/LuHR_showcode/sbym_picture/1e29460fd9f9d72abb1a7c3cd52a2834349bbb7e.jpg new file mode 100644 index 00000000..eb041a5b Binary files /dev/null and b/LuHR_showcode/sbym_picture/1e29460fd9f9d72abb1a7c3cd52a2834349bbb7e.jpg differ diff --git a/LuHR_showcode/sbym_picture/22f24eee3d6d55fb730d1a076c224f4a21a4dda9.jpg b/LuHR_showcode/sbym_picture/22f24eee3d6d55fb730d1a076c224f4a21a4dda9.jpg new file mode 100644 index 00000000..065acc86 Binary files /dev/null and b/LuHR_showcode/sbym_picture/22f24eee3d6d55fb730d1a076c224f4a21a4dda9.jpg differ diff --git a/LuHR_showcode/sbym_picture/2ab8b4cc7cd98d1007656010203fb80e7aec90c6.jpg b/LuHR_showcode/sbym_picture/2ab8b4cc7cd98d1007656010203fb80e7aec90c6.jpg new file mode 100644 index 00000000..3065f3f2 Binary files /dev/null and b/LuHR_showcode/sbym_picture/2ab8b4cc7cd98d1007656010203fb80e7aec90c6.jpg differ diff --git a/LuHR_showcode/sbym_picture/3d77a41bb051f81911fd6f6bdbb44aed2f73e798.jpg b/LuHR_showcode/sbym_picture/3d77a41bb051f81911fd6f6bdbb44aed2f73e798.jpg new file mode 100644 index 00000000..2c9cc6a8 Binary files /dev/null and b/LuHR_showcode/sbym_picture/3d77a41bb051f81911fd6f6bdbb44aed2f73e798.jpg differ diff --git a/LuHR_showcode/sbym_picture/4e8839738bd4b31c197bf89a86d6277f9e2ff835.jpg b/LuHR_showcode/sbym_picture/4e8839738bd4b31c197bf89a86d6277f9e2ff835.jpg new file mode 100644 index 00000000..6407fe01 Binary files /dev/null and b/LuHR_showcode/sbym_picture/4e8839738bd4b31c197bf89a86d6277f9e2ff835.jpg differ diff --git a/LuHR_showcode/sbym_picture/4f53bbaf2edda3cc783dd40100e93901203f929e.jpg b/LuHR_showcode/sbym_picture/4f53bbaf2edda3cc783dd40100e93901203f929e.jpg new file mode 100644 index 00000000..021ce999 Binary files /dev/null and b/LuHR_showcode/sbym_picture/4f53bbaf2edda3cc783dd40100e93901203f929e.jpg differ diff --git a/LuHR_showcode/sbym_picture/534906dfa9ec8a13d5853bc1f603918fa1ecc0dd.jpg b/LuHR_showcode/sbym_picture/534906dfa9ec8a13d5853bc1f603918fa1ecc0dd.jpg new file mode 100644 index 00000000..14db551d Binary files /dev/null and b/LuHR_showcode/sbym_picture/534906dfa9ec8a13d5853bc1f603918fa1ecc0dd.jpg differ diff --git a/LuHR_showcode/sbym_picture/5603c7160924ab18fc6c8d1634fae6cd7b890b79.jpg b/LuHR_showcode/sbym_picture/5603c7160924ab18fc6c8d1634fae6cd7b890b79.jpg new file mode 100644 index 00000000..86ab9cab Binary files /dev/null and b/LuHR_showcode/sbym_picture/5603c7160924ab18fc6c8d1634fae6cd7b890b79.jpg differ diff --git a/LuHR_showcode/sbym_picture/6f06e1246b600c335356b1e91b4c510fd9f9a14d.jpg b/LuHR_showcode/sbym_picture/6f06e1246b600c335356b1e91b4c510fd9f9a14d.jpg new file mode 100644 index 00000000..31c6c35e Binary files /dev/null and b/LuHR_showcode/sbym_picture/6f06e1246b600c335356b1e91b4c510fd9f9a14d.jpg differ diff --git a/LuHR_showcode/sbym_picture/726c5c36acaf2edda06725c88c1001e9380193e5.jpg b/LuHR_showcode/sbym_picture/726c5c36acaf2edda06725c88c1001e9380193e5.jpg new file mode 100644 index 00000000..3d23ecc5 Binary files /dev/null and b/LuHR_showcode/sbym_picture/726c5c36acaf2edda06725c88c1001e9380193e5.jpg differ diff --git a/LuHR_showcode/sbym_picture/7d541d55b319ebc43fcf1ab88326cffc1f1716c4.jpg b/LuHR_showcode/sbym_picture/7d541d55b319ebc43fcf1ab88326cffc1f1716c4.jpg new file mode 100644 index 00000000..7e9106fa Binary files /dev/null and b/LuHR_showcode/sbym_picture/7d541d55b319ebc43fcf1ab88326cffc1f1716c4.jpg differ diff --git a/LuHR_showcode/sbym_picture/86674dafa40f4bfb85a9f275024f78f0f736187e.jpg b/LuHR_showcode/sbym_picture/86674dafa40f4bfb85a9f275024f78f0f736187e.jpg new file mode 100644 index 00000000..20b98c5a Binary files /dev/null and b/LuHR_showcode/sbym_picture/86674dafa40f4bfb85a9f275024f78f0f736187e.jpg differ diff --git a/LuHR_showcode/sbym_picture/908be71f3a292df5c3b8c034bd315c6034a87378.jpg b/LuHR_showcode/sbym_picture/908be71f3a292df5c3b8c034bd315c6034a87378.jpg new file mode 100644 index 00000000..fd7a56ea Binary files /dev/null and b/LuHR_showcode/sbym_picture/908be71f3a292df5c3b8c034bd315c6034a87378.jpg differ diff --git a/LuHR_showcode/sbym_picture/948a61c6a7efce1b84e2a4ebae51f3deb58f65ae.jpg b/LuHR_showcode/sbym_picture/948a61c6a7efce1b84e2a4ebae51f3deb58f65ae.jpg new file mode 100644 index 00000000..dae2f1d9 Binary files /dev/null and b/LuHR_showcode/sbym_picture/948a61c6a7efce1b84e2a4ebae51f3deb58f65ae.jpg differ diff --git a/LuHR_showcode/sbym_picture/9b58efdcd100baa19dd02b9a4610b912c9fc2ef3.jpg b/LuHR_showcode/sbym_picture/9b58efdcd100baa19dd02b9a4610b912c9fc2ef3.jpg new file mode 100644 index 00000000..164abf24 Binary files /dev/null and b/LuHR_showcode/sbym_picture/9b58efdcd100baa19dd02b9a4610b912c9fc2ef3.jpg differ diff --git a/LuHR_showcode/sbym_picture/b32054a98226cffc9283d393b8014a90f703eacf.jpg b/LuHR_showcode/sbym_picture/b32054a98226cffc9283d393b8014a90f703eacf.jpg new file mode 100644 index 00000000..816c2779 Binary files /dev/null and b/LuHR_showcode/sbym_picture/b32054a98226cffc9283d393b8014a90f703eacf.jpg differ diff --git a/LuHR_showcode/sbym_picture/b85ba63533fa828b9a56f1c2fc1f4134970a5a7a.jpg b/LuHR_showcode/sbym_picture/b85ba63533fa828b9a56f1c2fc1f4134970a5a7a.jpg new file mode 100644 index 00000000..d1ffc25f Binary files /dev/null and b/LuHR_showcode/sbym_picture/b85ba63533fa828b9a56f1c2fc1f4134970a5a7a.jpg differ diff --git a/LuHR_showcode/sbym_picture/bcfcbe014c086e06b659536a03087bf40bd1cb87.jpg b/LuHR_showcode/sbym_picture/bcfcbe014c086e06b659536a03087bf40bd1cb87.jpg new file mode 100644 index 00000000..b508fbcb Binary files /dev/null and b/LuHR_showcode/sbym_picture/bcfcbe014c086e06b659536a03087bf40bd1cb87.jpg differ diff --git a/LuHR_showcode/sbym_picture/d05a9094a4c27d1e8f0454e51ad5ad6eddc43851.jpg b/LuHR_showcode/sbym_picture/d05a9094a4c27d1e8f0454e51ad5ad6eddc43851.jpg new file mode 100644 index 00000000..1ed96812 Binary files /dev/null and b/LuHR_showcode/sbym_picture/d05a9094a4c27d1e8f0454e51ad5ad6eddc43851.jpg differ diff --git a/LuHR_showcode/sbym_picture/d3af6ccb0a46f21f6e583272f7246b600c33ae0c.jpg b/LuHR_showcode/sbym_picture/d3af6ccb0a46f21f6e583272f7246b600c33ae0c.jpg new file mode 100644 index 00000000..4568b4e5 Binary files /dev/null and b/LuHR_showcode/sbym_picture/d3af6ccb0a46f21f6e583272f7246b600c33ae0c.jpg differ diff --git a/LuHR_showcode/sbym_picture/d56ca4de9c82d158f8c63590810a19d8bc3e422b.jpg b/LuHR_showcode/sbym_picture/d56ca4de9c82d158f8c63590810a19d8bc3e422b.jpg new file mode 100644 index 00000000..dbf44e40 Binary files /dev/null and b/LuHR_showcode/sbym_picture/d56ca4de9c82d158f8c63590810a19d8bc3e422b.jpg differ diff --git a/LuHR_showcode/sbym_picture/d57664f082025aafd86712eafaedab64034f1a1a.jpg b/LuHR_showcode/sbym_picture/d57664f082025aafd86712eafaedab64034f1a1a.jpg new file mode 100644 index 00000000..e0cf1abd Binary files /dev/null and b/LuHR_showcode/sbym_picture/d57664f082025aafd86712eafaedab64034f1a1a.jpg differ diff --git a/LuHR_showcode/sbym_picture/e2a86c899e510fb37db71bb6d833c895d0430ccd.jpg b/LuHR_showcode/sbym_picture/e2a86c899e510fb37db71bb6d833c895d0430ccd.jpg new file mode 100644 index 00000000..5e1e9c77 Binary files /dev/null and b/LuHR_showcode/sbym_picture/e2a86c899e510fb37db71bb6d833c895d0430ccd.jpg differ diff --git a/LuHR_showcode/sbym_picture/f266648da9773912203bea40f9198618367ae253.jpg b/LuHR_showcode/sbym_picture/f266648da9773912203bea40f9198618367ae253.jpg new file mode 100644 index 00000000..563b5f6d Binary files /dev/null and b/LuHR_showcode/sbym_picture/f266648da9773912203bea40f9198618367ae253.jpg differ diff --git a/LuHR_showcode/sbym_picture/f6b6402c11dfa9ec3fd93a3663d0f703908fc185.jpg b/LuHR_showcode/sbym_picture/f6b6402c11dfa9ec3fd93a3663d0f703908fc185.jpg new file mode 100644 index 00000000..b670f856 Binary files /dev/null and b/LuHR_showcode/sbym_picture/f6b6402c11dfa9ec3fd93a3663d0f703908fc185.jpg differ diff --git a/LuHR_showcode/sbym_picture/f97a5634970a304e67c8ccdbd0c8a786c8175c89.jpg b/LuHR_showcode/sbym_picture/f97a5634970a304e67c8ccdbd0c8a786c8175c89.jpg new file mode 100644 index 00000000..7905fe40 Binary files /dev/null and b/LuHR_showcode/sbym_picture/f97a5634970a304e67c8ccdbd0c8a786c8175c89.jpg differ diff --git a/LuHR_showcode/test/base.html b/LuHR_showcode/test/base.html new file mode 100644 index 00000000..7df62a0b --- /dev/null +++ b/LuHR_showcode/test/base.html @@ -0,0 +1,43 @@ + + + + + + + + + + + + + First bootstrap page + + + + +
+
+
+

+ input here: + +
+
+
+ + + + +> \ No newline at end of file diff --git a/LuHR_showcode/test/x0000.py b/LuHR_showcode/test/x0000.py new file mode 100644 index 00000000..9883d94c --- /dev/null +++ b/LuHR_showcode/test/x0000.py @@ -0,0 +1,18 @@ +from PIL import Image,ImageDraw,ImageFont + +def add_num( imgPath, color = "#ff0000", msg = '4'): + try: + img = Image.open(imgPath, 'r') + draw = ImageDraw.Draw(img) + imagefont = ImageFont.truetype('C:/Windows/Fonts/Arial.ttf', 40) + width, height = img.size + + draw.text( (width - 40, 0),msg, font=imagefont, fill=color) #宸︿笂瑙掍负鍘熺偣锛孻杞村悜涓 + img.save('result.jpg', 'jpeg') + + except: + print("can't load picture") + +if __name__ == "__main__": + add_num('D:/git/Project/picture/showcode/picture01.jpg',msg = '5') + diff --git a/LuHR_showcode/test/x0001.py b/LuHR_showcode/test/x0001.py new file mode 100644 index 00000000..3f4bfc6f --- /dev/null +++ b/LuHR_showcode/test/x0001.py @@ -0,0 +1,18 @@ +#鍋氫负 Apple Store App 鐙珛寮鍙戣咃紝浣犺鎼為檺鏃朵績閿锛 +# 涓轰綘鐨勫簲鐢ㄧ敓鎴愭縺娲荤爜锛堟垨鑰呬紭鎯犲埜锛夛紝浣跨敤 Python 濡備綍鐢熸垚 200 涓縺娲荤爜锛堟垨鑰呬紭鎯犲埜锛 +import string +import random + +def get_ACCode(length=20,number= 200): + + chars =string.ascii_letters + string.digits + AC_list = [] + for i in range(number): + str = '' + for j in range(length): + str += random.choice(chars) + AC_list.append(str) + return AC_list +if __name__=='__main__': + list = get_ACCode() + print (list[1:200]) \ No newline at end of file diff --git a/LuHR_showcode/test/x0009.py b/LuHR_showcode/test/x0009.py new file mode 100644 index 00000000..3d63aeb5 --- /dev/null +++ b/LuHR_showcode/test/x0009.py @@ -0,0 +1,10 @@ +from bs4 import BeautifulSoup +from urllib.request import urlopen + +url = 'https://www.cnblogs.com/jasondan/p/3497757.html' +r = urlopen(url).read() + +soup = BeautifulSoup(r) + +for i in soup.find_all('a'): + print(i.get('href')) diff --git a/LuHR_showcode/x0000.py b/LuHR_showcode/x0000.py new file mode 100644 index 00000000..803f229f --- /dev/null +++ b/LuHR_showcode/x0000.py @@ -0,0 +1,19 @@ +# 灏嗕綘鐨 QQ 澶村儚锛堟垨鑰呭井鍗氬ご鍍忥級鍙充笂瑙掑姞涓婄孩鑹茬殑鏁板瓧锛岀被浼间簬寰俊鏈淇℃伅鏁伴噺閭g鎻愮ず鏁堟灉銆 绫讳技浜庡浘涓晥鏋 +from PIL import Image,ImageDraw,ImageFont + +def add_num( imgPath, color = "#ff0000", msg = '4'): + try: + img = Image.open(imgPath, 'r') + draw = ImageDraw.Draw(img) + imagefont = ImageFont.truetype('C:/Windows/Fonts/Arial.ttf', 40) + width, height = img.size + + draw.text( (width - 40, 0),msg, font=imagefont, fill=color) #宸︿笂瑙掍负鍘熺偣锛孻杞村悜涓 + img.save('result.jpg', 'jpeg') + + except: + print("can't load picture") + +if __name__ == "__main__": + add_num('D:/git/Project/picture/showcode/picture01.jpg',msg = '5') + diff --git a/LuHR_showcode/x0001.py b/LuHR_showcode/x0001.py new file mode 100644 index 00000000..3f4bfc6f --- /dev/null +++ b/LuHR_showcode/x0001.py @@ -0,0 +1,18 @@ +#鍋氫负 Apple Store App 鐙珛寮鍙戣咃紝浣犺鎼為檺鏃朵績閿锛 +# 涓轰綘鐨勫簲鐢ㄧ敓鎴愭縺娲荤爜锛堟垨鑰呬紭鎯犲埜锛夛紝浣跨敤 Python 濡備綍鐢熸垚 200 涓縺娲荤爜锛堟垨鑰呬紭鎯犲埜锛 +import string +import random + +def get_ACCode(length=20,number= 200): + + chars =string.ascii_letters + string.digits + AC_list = [] + for i in range(number): + str = '' + for j in range(length): + str += random.choice(chars) + AC_list.append(str) + return AC_list +if __name__=='__main__': + list = get_ACCode() + print (list[1:200]) \ No newline at end of file diff --git a/LuHR_showcode/x0002.py b/LuHR_showcode/x0002.py new file mode 100644 index 00000000..e1ac7d2e --- /dev/null +++ b/LuHR_showcode/x0002.py @@ -0,0 +1,34 @@ +# 0001 棰樼敓鎴愮殑 200 涓縺娲荤爜锛堟垨鑰呬紭鎯犲埜锛変繚瀛樺埌 MySQL 鍏崇郴鍨嬫暟鎹簱涓 +import x0001 +import pymysql + +def store_mysql(codelist): + try: + conn = pymysql.connect(host="192.168.100.123",user="root",password="mysql123",db="mysql",port=3306) + cur = conn.cursor() + except BaseException as e: + print(e) + else: + try: + cur.execute('CREATE DATABASE IF NOT EXISTS pydb_test') + cur.execute('use pydb_test') + sql = '''CREATE TABLE IF NOT EXISTS ACcode( + id INT NOT NULL AUTO_INCREMENT, + code VARCHAR(64) NOT NULL, + primary key (id) + )''' + cur.execute(sql) + + for ch in list1: + cur.execute('INSERT INTO ACcode (code) values (%s)', (ch) ) + cur.connection.commit() + except BaseException as e: + print(e) + finally: + cur.close() + conn.close() + +if __name__=='__main__': + list1 = x0001.get_ACCode() + store_mysql(list1) + diff --git a/LuHR_showcode/x0003.py b/LuHR_showcode/x0003.py new file mode 100644 index 00000000..29f8a5b8 --- /dev/null +++ b/LuHR_showcode/x0003.py @@ -0,0 +1,24 @@ +#灏 0001 棰樼敓鎴愮殑 200 涓縺娲荤爜锛堟垨鑰呬紭鎯犲埜锛変繚瀛樺埌 Redis 闈炲叧绯诲瀷鏁版嵁搴撲腑銆 +import redis +import x0001 + +redisHost = '192.168.100.123' +redisPort = 6379 + +def storeRedis(codelist): + r = redis.StrictRedis(host=redisHost, port=redisPort) + for i in range(len(codelist)): + r.set('key_'+ str(i), codelist[i - 1]) + +def searchRedis(): + r = redis.StrictRedis(host=redisHost, port=redisPort,db=0) + b = int(input('Search Active code锛1-200锛夛細')) + value = r.get('key_' + str(b)) + print(value) + + + +if __name__ == '__main__': + codelist = x0001.get_ACCode(20,5) + storeRedis(codelist) + searchRedis() diff --git a/LuHR_showcode/x0004.py b/LuHR_showcode/x0004.py new file mode 100644 index 00000000..287cd7be --- /dev/null +++ b/LuHR_showcode/x0004.py @@ -0,0 +1,45 @@ +#coding:utf-8 +#浠讳竴涓嫳鏂囩殑绾枃鏈枃浠讹紝缁熻鍏朵腑鐨勫崟璇嶅嚭鐜扮殑涓暟銆 +import re + +def readFile(file = 'input.txt'): + try: + with open(file,'r',encoding='UTF-8') as f: + txts = f.read() + except BaseException as e: + print(e) + return txts + + +def getEwordsCount(txts): + words = re.compile('([a-zA-Z]+)') + dic = {} + for x in words.findall(txts): + if x not in dic: + dic[x] = 1 + else: + dic[x] += 1 + + L = [] + for k,v in dic.items(): #items浠ュ垪琛ㄨ繑鍥炲彲閬嶅巻鐨(閿, 鍊) 鍏冪粍鏁扮粍 + L.append((k, v)) + + # return L.sort( key = lambda t:t[0]) + L.sort( key = lambda t:t[0]) + return L + +if __name__ == '__main__': + txts = readFile() + list1 = getEwordsCount(txts) + print(list1) + + + + + + + + + + + diff --git a/LuHR_showcode/x0005.py b/LuHR_showcode/x0005.py new file mode 100644 index 00000000..33957a96 --- /dev/null +++ b/LuHR_showcode/x0005.py @@ -0,0 +1,20 @@ +import os +from PIL import Image + +path = 'D:\git\Project\picture\showcode' + +def change_picSize(fileName,width = 1136,hight = 640): + img = Image.open(fileName) + + img.thumbnail((width, hight))#鍙兘鍙樺皬 + img.save(fileName) + print (fileName + ' DONE!') + +PHONE = {'iPhone5':(1136,640), 'iPhone6':(1134,750), 'iPhone6P':(2208,1242)} +files = os.listdir(path) +width,height = PHONE['iPhone6P'] +for fileName in files: + portion = os.path.splitext(fileName) + if portion[1] == ".jpg" or portion[1] == ".png": + change_picSize(fileName,width,height) + diff --git a/LuHR_showcode/x0006.py b/LuHR_showcode/x0006.py new file mode 100644 index 00000000..e5bad198 --- /dev/null +++ b/LuHR_showcode/x0006.py @@ -0,0 +1,26 @@ +import os +import x0004 + +# 鑾峰彇鍒楄〃鐨勭浜屼釜鍏冪礌 +def takesecond(e): + return e[1] + +path = 'D:\git\Project\picture\showcode' + +files = os.listdir(path) + +txts = '' +for fileName in files: + portion = os.path.splitext(fileName) + if portion[1] == '.txt': + txts += x0004.readFile(fileName) + +listAll = x0004.getEwordsCount(txts) +# listAll.sort( key = lambda t:t[1],reverse=True) +listAll.sort(key=takesecond,reverse=True) + +print (listAll) + + + + diff --git a/LuHR_showcode/x0007.py b/LuHR_showcode/x0007.py new file mode 100644 index 00000000..ea4476cb --- /dev/null +++ b/LuHR_showcode/x0007.py @@ -0,0 +1,46 @@ +#鏈変釜鐩綍锛岄噷闈㈡槸浣犺嚜宸卞啓杩囩殑绋嬪簭锛岀粺璁′竴涓嬩綘鍐欒繃澶氬皯琛屼唬鐮併傚寘鎷┖琛屽拰娉ㄩ噴锛屼絾鏄鍒嗗埆鍒楀嚭鏉ャ +import os +from collections import Counter + + +def AnalyseCode(file): + with open( file,'r',encoding='UTF-8') as f: + txts =f.readlines() + dicTemp = {"codeNum":0, "commentsNum":0, "EmptylineNum":0} + it = iter(txts) + incomment = False + for line in it:#杩唬鍣 + if line in ['\n','\r\n']: + dicTemp['EmptylineNum'] += 1 + elif line.startswith("#") : + dicTemp['commentsNum'] +=1 + elif line.startswith("'''") or line.startswith('"""'): + dicTemp['commentsNum'] += 1 + incomment = not incomment + else: + if incomment == False: + dicTemp['codeNum'] += 1 + else: + dicTemp['commentsNum'] += 1 + return dicTemp + +def AnylyseFileAllCode(dir, fileType = ['.py', '.html']): + + dicTotal = {"codeNum":0, "commentsNum":0, "EmptylineNum":0} + for file in os.listdir(dir): + portion = os.path.splitext(file) + if portion[1] in fileType: + dicTemp = AnalyseCode(dir + '/' + file ) + dicTotal =dict( Counter(dicTotal) + Counter(dicTemp) ) + return dicTotal + + + +if __name__=='__main__': + dir = r'D:\git\Project\picture\showcode\test' + dicTotal = AnylyseFileAllCode(dir) + print(dicTotal) + + + + diff --git a/LuHR_showcode/x0008.py b/LuHR_showcode/x0008.py new file mode 100644 index 00000000..ad4e60cb --- /dev/null +++ b/LuHR_showcode/x0008.py @@ -0,0 +1,18 @@ + +from urllib.request import urlopen +from bs4 import BeautifulSoup + + +url = 'https://www.cnblogs.com/jasondan/p/3497757.html' +r = urlopen(url).read() + +soup = BeautifulSoup(r) + +t = soup.find_all('body') + +s = '' +for i in t[0].find_all(['p','li','h2','h3']): + s += i.get_text() + '\n' + +print(s) + diff --git a/LuHR_showcode/x0010.py b/LuHR_showcode/x0010.py new file mode 100644 index 00000000..0cee21b4 --- /dev/null +++ b/LuHR_showcode/x0010.py @@ -0,0 +1,36 @@ +#浣跨敤 Python 鐢熸垚绫讳技浜庝笅鍥句腑鐨勫瓧姣嶉獙璇佺爜鍥剧墖 +import x0001 +import random +from PIL import ImageDraw,Image,ImageFont,ImageFilter + +width = 400 +height = 200 + +def randonColor(): + return ( random.randint(0,255),random.randint(0,255),random.randint(0,255) ) + +def drawBackground(noiseRate = 50): + img = Image.new('RGB', (width, height), (0,0,0)) + imgDraw = ImageDraw.Draw(img) + for i in range(width): + for j in range(height): + if ( random.randint(1,100) < noiseRate ): + imgDraw.point((i,j),randonColor()) + #draw font + fontsize = 80 + imagefont = ImageFont.truetype('arial.ttf', fontsize) + fontcolor = "#ff0000" + msg = x0001.get_ACCode(4, 1)[0] + + font_width, font_height = imagefont.getsize(msg) + x = 0 + y = 60 + i = 0 + for ch in msg: + i+=1 + x = 16 *i+ (i -1)* 80 + imgDraw.text((x, y), ch, fontcolor,imagefont) + img = img.filter(ImageFilter.BLUR) + img.save('backpic.jpg') + +drawBackground() \ No newline at end of file diff --git a/LuHR_showcode/x0011.py b/LuHR_showcode/x0011.py new file mode 100644 index 00000000..7a742286 --- /dev/null +++ b/LuHR_showcode/x0011.py @@ -0,0 +1,26 @@ +#鏁忔劅璇嶆枃鏈枃浠 filtered_words.txt锛岄噷闈㈢殑鍐呭涓轰互涓嬪唴瀹癸紝褰撶敤鎴疯緭鍏ユ晱鎰熻瘝璇椂锛屽垯鎵撳嵃鍑 Freedom锛屽惁鍒欐墦鍗板嚭 Human Rights銆 +def readFile(file = 'filtered_words.txt'): + try: + with open(file,'r',encoding='gbk') as f: + txts = f.readlines() + return txts + except BaseException as e: + print(e) + +def checkWords(input_words): + flag = False + txts = readFile() + for ch in txts: + ch1 = ch.replace('\n', '') + if ch1 == input_words: + flag = True + break + return flag +if __name__ == '__main__': + + while True: + input_words = input("Please input:") + if checkWords(input_words): #鏁忔劅 + print('Freedom') + else: + print('Human Rights') diff --git a/LuHR_showcode/x0012.py b/LuHR_showcode/x0012.py new file mode 100644 index 00000000..29d9de0a --- /dev/null +++ b/LuHR_showcode/x0012.py @@ -0,0 +1,23 @@ +#鏁忔劅璇嶆枃鏈枃浠 filtered_words.txt锛岄噷闈㈢殑鍐呭 鍜 0011棰樹竴鏍凤紝褰撶敤鎴疯緭鍏ユ晱鎰熻瘝璇紝鍒欑敤 鏄熷彿 * 鏇挎崲锛 +# 渚嬪褰撶敤鎴疯緭鍏ャ屽寳浜槸涓ソ鍩庡競銆嶏紝鍒欏彉鎴愩**鏄釜濂藉煄甯傘嶃' + +import x0011 +#txts = readFile() +def readFile(): + try: + with open('filtered_words.txt',encoding='gbk') as f: + fWordsList = f.read().split('\n') + return fWordsList + except BaseException as e: + print(e) + +def changeWords(inputWords): + fWordsList = readFile() + for word in fWordsList: + if word in inputWords: + inputWords = inputWords.replace(word, '*'*len(word)) + print(inputWords) + +while True: + inputWords = input("Please input:") + changeWords(inputWords) \ No newline at end of file diff --git a/LuHR_showcode/x0013.py b/LuHR_showcode/x0013.py new file mode 100644 index 00000000..9ff69be7 --- /dev/null +++ b/LuHR_showcode/x0013.py @@ -0,0 +1,24 @@ +#coding:utf-8 +import requests, re, os + +url = 'http://tieba.baidu.com/p/2166231880' + +header = { + 'Accept': '*/*', + 'Accept-Encoding':'gzip,deflate,sdch', + 'Accept-Language':'zh-CN,zh;q=0.8', + 'Connection':'keep-alive' + } +html = requests.get(url,headers = header) + +data = html.content.decode('utf-8') +find = re.compile(r'