This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ptyhon | |
| #coding:UTF-8 | |
| import requests, json, re | |
| html = requests.get('http://www.chimei.org.tw/%E6%80%A5%E8%A8%BA%E5%8D%B3%E6%99%82%E8%A8%8A%E6%81%AF/main.aspx') | |
| pending = re.findall('">(.+?)</font>',html.text)[35:] | |
| pending[2:4] = [] | |
| values = [ int(ele) for ele in pending[1:] ] | |
| keys = ['pending_doctor', 'pending_ward', 'pending_icu', 'pending_bed'] | |
| report = { key:value for value, key in zip(values, keys) } |
We can't make this file beautiful and searchable because it's too large.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| hospital name, serial number | |
| 衛生福利部臺北醫院城區分院, 0101090019 | |
| 臺北市立聯合醫院, 0101090517 | |
| 衛生福利部基隆醫院, 0111070010 | |
| 新北市立聯合醫院, 0131020016 | |
| 衛生福利部樂生療養院, 0131060010 | |
| 衛生福利部臺北醫院, 0131060029 | |
| 衛生福利部八里療養院, 0131230012 | |
| 衛生福利部金門醫院, 0190030516 | |
| 基隆市立醫院, 0211070012 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| def print_lol(the_list,indent=False,level=0,fh=sys.stdout): | |
| for each_item in the_list: | |
| if isinstance(each_item,list): | |
| print_lol(each_item,indent,level+1,fh) | |
| else: | |
| if indent: | |
| for tab_stop in range(level): | |
| print("\t",end='',file=fh) | |
| print(each_item,file=fh) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| #coding:utf8 | |
| from datetime import datetime | |
| from influxdb import InfluxDBClient | |
| import fileinput | |
| import ast | |
| client = InfluxDBClient("localhost", 8086, 'guest', 'guest', 'twER') | |
| files = open('temp').read().splitlines() | |
| points =[] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| >>> print('\n'.join([''.join(["%d*%d=%2s "%(i,j,i*j) for i in range(1,10)]) for j in range(1,10)])) | |
| 1*1= 1 2*1= 2 3*1= 3 4*1= 4 5*1= 5 6*1= 6 7*1= 7 8*1= 8 9*1= 9 | |
| 1*2= 2 2*2= 4 3*2= 6 4*2= 8 5*2=10 6*2=12 7*2=14 8*2=16 9*2=18 | |
| 1*3= 3 2*3= 6 3*3= 9 4*3=12 5*3=15 6*3=18 7*3=21 8*3=24 9*3=27 | |
| 1*4= 4 2*4= 8 3*4=12 4*4=16 5*4=20 6*4=24 7*4=28 8*4=32 9*4=36 | |
| 1*5= 5 2*5=10 3*5=15 4*5=20 5*5=25 6*5=30 7*5=35 8*5=40 9*5=45 | |
| 1*6= 6 2*6=12 3*6=18 4*6=24 5*6=30 6*6=36 7*6=42 8*6=48 9*6=54 | |
| 1*7= 7 2*7=14 3*7=21 4*7=28 5*7=35 6*7=42 7*7=49 8*7=56 9*7=63 | |
| 1*8= 8 2*8=16 3*8=24 4*8=32 5*8=40 6*8=48 7*8=56 8*8=64 9*8=72 | |
| 1*9= 9 2*9=18 3*9=27 4*9=36 5*9=45 6*9=54 7*9=63 8*9=72 9*9=81 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import time | |
| from zipfile import ZipFile | |
| def unpack(filename, extract_dir=None): | |
| if not extract_dir: | |
| extract_dir = os.path.basename(filename).replace('.zip', '') | |
| with ZipFile(filename) as zf: | |
| for zi in zf.infolist(): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def primes(start, end): | |
| """ return an generator for primes in range. | |
| >>> next(primes(2,3)) | |
| 2 | |
| >>> list(primes(2,3)) | |
| [2] | |
| >>> list(primes(1,3)) | |
| [1, 2] | |
| >>> list(primes(5,3)) | |
| [3] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def bi_exp_tree(expstr): | |
| """ infix to postfix. | |
| >>> bi_exp_tree("(a+(b*c))") | |
| 'abc*+' | |
| >>> bi_exp_tree("((a+b)*(z+x))") | |
| 'ab+zx+*' | |
| >>> bi_exp_tree("((a+t)*((b+(a+c))^(c+d)))") | |
| 'at+bac++cd+^*' | |
| """ | |
| result = "" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def rm_dict(dicts, keyword, recursive=True): | |
| """ remove a keyword(k-v pair) from (nest) dict. default is recursived. | |
| :param: dicts - an dict (nested allow). | |
| :param: keyword - an tuple with 2 values, means (key, value). | |
| :param: recursive - recursive search, default is True. | |
| ... admonition : doctest string below. | |
| pretty a as: | |
| a = \ | |
| { | |
| 'name':'adam', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def try_else(x, y): | |
| a = lambda x, y: x % y | |
| b = lambda x, y: x / y | |
| try: | |
| result = a(x,y) + b(x,y) | |
| f = open('Cookie', 'w+') | |
| except ZeroDivisionError as z: | |
| print(z) | |
| # divide by zero. | |
| except PermissionError as p: |