每月彙整:一月 2023

python-Decorator

https://www.youtube.com/watch?v=qc8hsxAK270&list=PL-g0fdC5RMboYEyt6QS2iLb_1m7QcgfHk&index=34 定義裝飾器 def 定義裝飾器(回呼函式): def 內部函式(): #裝飾器函式內碼 回呼函式名稱() return 內部函式名稱 使用裝飾器 @裝飾器名稱 def 函式名稱(): #函式程式碼 函式名稱() #呼叫帶有裝飾器名稱 範例: def testDecorator(callback): def innerFunc(): callback() return innerFunc @testDecorator def decoratedFunc(): print("普通函式") defcoratedFunc() =============== #定義裝飾器 def myDeco(cb): def run(): print("1.裝飾器中的程式碼") cb(5) #這回呼函式,其實是被裝式的函式 test … 繼續閱讀 →

發表於 python | 發表迴響

Python – call back

#callback def test(arg): #print(arg) arg("hello") # function call #arg(hello) to handle(data) #定義一個回呼函式 def handle(data): print(data) test(handle) def add(n1, n2, cb): cb(n1+n2) def handle1(result): print("結果是: ", result ) def handle2(result): print("English Result of Add is: ", result ) add(3, 4, handle1) … 繼續閱讀 →

發表於 python | 發表迴響

python selenium-3

標籤ID driver.find_element(By.ID,"條件") 標籤屬性搜尋 CSS driver.find_element(By.CSS_SELECTOR,"[屬性名稱=屬性的值]") 模擬user input element=driver.find_elemnet(search欄位,"條件") element.send_keys("input key) 模擬 user inpurt key element.send_keys(Keys.ENTER) ======================================= #https://www.youtube.com/watch?v=tR558fQAHz8 #爬 leetcode #https://leetcode.com/accounts/login/ #pip install selenium from selenium import webdriver from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.by import By from selenium.webdriver.chrome.options import Options import … 繼續閱讀 →

發表於 python | 發表迴響

python selenium-2

瀏覽器中執行程式 driver.execute_script("JavaScript Code") 捲動視窗到底部 dirver.execute_script("window.scrollTo(0,document.body.scrollHeight);)") 等待一陣子在捲動 imprt time time.sleep("wait s") ========================== #https://www.youtube.com/watch?v=ZOxIpMTgaXY #https://www.linkedin.com/jobs/search?trk=guest_homepage-basic_guest_nav_menu_jobs&position=1&pageNum=0 #爬linkin #pip install selenium from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.chrome.options import Options import time #wating html loading #chrom driver path https://chromedriver.chromium.org/downloads options=Options() options.chrome_executable_path="G:\我的雲端硬碟\PY\練習\chromdriver" … 繼續閱讀 →

發表於 python | 發表迴響

python selenium-1

https://www.youtube.com/watch?v=ff5L6L5MTCw 取得標籤範例: BY LINK drive.find_element(By.LINK_TEXT,"要搜尋文字") BY CLASS drive.find_element(By.CLASS_NAME,"要搜尋文字") 操作標籤: 取得標籤內部文字: element=drive.find_element(搜尋欄位,"要搜尋條件") element.text 取得標籤屬性: element=drive.find_element(搜尋欄位,"要搜尋條件") element.get_attribute("屬性名稱") 模擬click: element=drive.find_element(搜尋欄位,"要搜尋條件") element.click(). ===================== #爬ppt stock #pip install selenium #https://www.ptt.cc/bbs/Stock/index.html from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.chrome.options import Options #chrom driver path … 繼續閱讀 →

發表於 python | 發表迴響

關閉 windows smb cache

cmd /WRITETHROUGH 關閉 smb 緩存

發表於 windows | 發表迴響

linux-bmon

https://linux.cn/article-8392-1.html 查看特定網卡 bmon -p enps0 查看每秒位元數 bmon -bp enps0 每5秒變更 bmon -r 5 -p enps0 bmon 有很多能提供网卡统计数据的输入模块,其中包括: netlink – 使用 Netlink 协议从内核中收集网卡和流量控制统计信息。这是默认的输入模块。 proc – 从 /proc/net/dev 文件读取网卡统计信息。它被认为是传统界面,且提供了向后兼容性。它是 Netlink 接口不可用时的备用模块。 dummy – 这是用于调试和测试的可编程输入模块。 null – 停用数据收集。 bmon -i netlink:help bmon -i … 繼續閱讀 →

發表於 Network, linux | 發表迴響

Dock-comper-DNS SERVER

#dns #https://www.youtube.com/watch?v=syzwLwE3Xq4&t=1290s vim named.conf #允許LAN acl internal { 10.10.0.0/16; 10.11.0.0/16; 10.20.0.0/16; }; options { forwarders { 1.1.1.1; }; allow-query { internal; } }’ zone "demo.clcreative.de" in { type master; file "/etc/bind/demo-clcreative=de.zone"; }; #如果出現 ERROR: for bind9 can not start service … 繼續閱讀 →

發表於 未分類 | 已標籤 | 發表迴響

linux 使用crontab 開機後立刻執行

1.crontab -e 2. @reboot sleep 60 ; /root/my-shell.sh #開機60s後執行

發表於 未分類 | 已標籤 | 發表迴響

python

print %d 整數列印 %f float列印 %s string列印 %e 科學記號列印 %5d 固定列印 5位元 整數 ,少於5位元 左邊自動填入空白,大於5位元全部列印 %5s 固定列印 5位元 string ,少於5位元 左邊自動填入空白 ,大於5位元全部列印 %8.2f 固定列印 8位元 float 含小數點 %-8.2f 固定列印 8位元 float 含小數點 -右邊自動填入空白

發表於 python | 發表迴響