This file contains 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 random | |
def _3d1():#方法一,直接顯示 | |
return print(str(random.randint(0, 9)) + " " + str(random.randint(0, 9)) + " " + str(random.randint(0, 9))) | |
def _3d2():#方法二,一次抽一顆 | |
result = list() | |
_3d_ticket = set() | |
while len(_3d_ticket) < 3: | |
number = random.randint(0,9) | |
_3d_ticket.add(number) |
This file contains 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 numpy as np | |
import pandas as pd | |
samplesize = 100000 | |
Probability = np.random.choice([0,1,2,3,4,5,6,7,8,9], size=samplesize, p=[0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1]) | |
valueCount = pd.Series(Probability).value_counts() | |
print(valueCount/samplesize) |
This file contains 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
# -*- coding: utf-8 -*- | |
#參考https://blog.csdn.net/handsomekang/article/details/9397025 | |
#當資料庫中文字長度限制判斷時需要特別注意,要配合資料庫datatype | |
#許功蓋 大五碼 | |
print(len(u"測試".encode("utf-8")))#一個中文長度3 | |
print(len(u"測試".encode("Big5")))#一個中文長度2 | |
print(len(u"測試"))#unicode | |
#計算機 | |
print(3+2) | |
print(3-2) |
This file contains 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(8888) | |
#二進位0b | |
print(0b001) | |
print(0b010) | |
print(0b011) | |
#八進位0o | |
print(0o010) | |
print(0o011) | |
#十六進位0x |
This file contains 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 math | |
#真值表 and 只有TT才是True | |
print(True & True) | |
print(True & False) | |
print(False & True) | |
print(False & False) | |
#真值表 or 有T就是True | |
print(True | True) | |
print(True | False) | |
print(False | True) |
This file contains 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=<device-width>, initial-scale=1.0"> | |
<title>Document</title> | |
</head> | |
<body> | |
<table border="2" bordercolor="black"> | |
<tr> |
This file contains 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
# -*- coding: UTF-8 -*- | |
#取得高鐵站名 | |
import requests | |
import bs4 | |
url = 'https://www.thsrc.com.tw' | |
htmlfile = requests.get(url) | |
htmlfile.encoding = 'utf-8' | |
objSoup = bs4.BeautifulSoup(htmlfile.text, 'lxml') | |
stations = objSoup.find('select', id='select_location01').find_all('option') | |
for station in stations: |
This file contains 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
#https://blog.csdn.net/u014636245/article/details/83661559 | |
#pip install opencv-python (cv2) matplotlib numpy | |
#先定义颜色和对应的16进制值 | |
based = range(0,16) | |
based_palette = [ | |
"%02x" %l #转为16进制 | |
for l in based | |
] | |
colored = [0] + [0x5f + 40 * n for n in range(0, 5)] #array combined [0, 95, 135, 175, 215, 255] |
This file contains 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>ip location</title> | |
<script src="https://pv.sohu.com/cityjson"></script> | |
<script>document.write(returnCitySN["cip"]+"."+returnCitySN["cname"])</script> | |
</head> | |
<body> |
OlderNewer