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 img2pdf | |
import os | |
current_path = os.getcwd() | |
with open("output.pdf", "wb") as f: | |
f.write(img2pdf.convert([i for i in os.listdir(current_path) if i.endswith(".jpg")])) |
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 glob,os | |
import pdfkit #pip install pdfkit | |
path = r"C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe" | |
config = pdfkit.configuration(wkhtmltopdf=path) | |
newList=[] | |
for filename in glob.iglob(os.path.join('*.html')): | |
newList.append(filename) |
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
#originally from https://github.com/getlinksc/scrape_google | |
import urllib | |
import requests | |
from bs4 import BeautifulSoup | |
# desktop user-agent | |
USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:65.0) Gecko/20100101 Firefox/65.0" | |
# mobile user-agent | |
MOBILE_USER_AGENT = "Mozilla/5.0 (Linux; Android 7.0; SM-G930V Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.125 Mobile Safari/537.36" |
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
#Translate Any Language to English | |
from googletrans import Translator | |
translator = Translator() | |
print(translator.translate('星期日').text) | |
#on Sunday | |
#Translate English to Chinese | |
from googletrans import Translator | |
translator = Translator() | |
print(translator.translate('Sunday', dest='zh-tw').text) |
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
#just open your command line and type | |
pip install speedtest-cli | |
#and then test your speed with the command below | |
speedtest |
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
''' | |
Firebase是可以即時讀取的資料庫,主要以JSON格式為主。除了透過程式操作外,也能在Firebase的網頁界面上進行資料操作(上傳、讀取、修改、刪除) | |
''' | |
###程式1### | |
#引入模組 | |
from firebase import firebase | |
import time |
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
#Method(1)Using system default player | |
import os | |
os.system('test.mp3') | |
#Method(2)Using pygame | |
import pygame | |
pygame.mixer.init() | |
pygame.mixer.music.set_volume(1.0) |
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
''' | |
python3 "file.py" -arg arg | |
''' | |
#install fire | |
pip install fire | |
#Main code | |
import fire |
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 glob | |
>>> glob.glob('./[0-9].*') | |
['./1.gif', './2.txt'] | |
>>> glob.glob('*.gif') | |
['1.gif', 'card.gif'] | |
>>> glob.glob('?.gif') | |
['1.gif'] | |
>>> glob.glob('**/*.txt', recursive=True) | |
['2.txt', 'sub/3.txt'] | |
>>> glob.glob('./**/', recursive=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
#Install | |
pip install tqdm | |
#Usage | |
from tqdm import tqdm | |
for i in tqdm(range(10000)): | |
print(i) |