Skip to content

Instantly share code, notes, and snippets.

# -*- coding: utf-8 -*-
"""
Created on Mon Mar 13 17:13:17 2017
@author: goingcosme20
"""
import sys
import json
@linzino7
linzino7 / PythonDecorator.py
Created September 25, 2017 14:42
Python Decorator Pattern Example
# -*- coding: utf-8 -*-
"""
Created on Mon Sep 25 21:57:40 2017
@author: linzino
"""
#python Decorator Pattern
def print_my_name(name):
@linzino7
linzino7 / APS_TypeError.py
Created December 27, 2017 05:53
Python APScheduler:TypeError: func must be a callable or a textual reference to one
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Dec 26 16:18:35 2017
@author: zino
"""
from datetime import datetime
import time
@linzino7
linzino7 / APS_TypeError_fix_byargs.py
Created December 27, 2017 05:57
Python APScheduler:TypeError: func must be a callable or a textual reference to one . Fix by args.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Dec 26 16:18:35 2017
@author: zino
"""
@linzino7
linzino7 / APS_TypeError_fix_by__cell__.py
Created December 27, 2017 05:59
Python APScheduler:TypeError: func must be a callable or a textual reference to one . Fix by __cell__.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Dec 26 16:18:35 2017
@author: zino
"""
from datetime import datetime
import time
@linzino7
linzino7 / Python3decode.py
Created January 26, 2018 09:22
Python3 bytes.decode() 當遇到字串一樣時python 判別
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Jan 19 17:34:34 2018
當遇到字串一樣時python 判別
@author: zino
"""
class Command:
def redo(self, **kwargs):
abstract
def undo(self, **kwargs);
abstract
class UploadImgurCommand extend Command:
def redo(self, **kwargs):
image = kwargs['image'];
Sales CompPrice Income Advertising Population Price ShelveLoc Age Education Urban US
1 9.5 138 73 11 276 120 Bad 42 17 Yes Yes
2 11.22 111 48 16 260 83 Good 65 10 Yes Yes
3 10.06 113 35 10 269 80 Medium 59 12 Yes Yes
4 7.4 117 100 4 466 97 Medium 55 14 Yes Yes
5 4.15 141 64 3 340 128 Bad 38 13 Yes No
@linzino7
linzino7 / matplotlib_two_scales.py
Created January 15, 2019 09:13
X axis in matplotlib with different scales
# 將不同資料長度畫在不同的為度上
# ref https://matplotlib.org/examples/axes_grid/demo_parasite_axes2.html
import matplotlib.pyplot as plt
x_values1=[1,2,3,4,5]
y_values1=[1,2,2,4,1]
x_values2=[-1000,-800,-600,-400,-200,-100,0]
y_values2=[10,20,39,40,50,60,10]
@linzino7
linzino7 / example.py
Last active April 28, 2020 19:05
阻擋新手學習[多頁網路爬蟲]的關鍵資料處理思維-累加 (內含影片)
# -*- coding: utf-8 -*-
import random, string
def get_one_pagedata(i):
'''
假設這個function爬取某一網頁資料。
先用亂數給予一個英文大小寫文字替代。
'''
content = random.choice(string.ascii_letters)