建立Google
2021年1月30日 星期六
2020年12月17日 星期四
Python List Comprehension
List Comprehension沒有統一譯名(數學推論出的式子)
#列表推導式
# 列表高效率單行建構
arr1 = [i for i in range(10)]
# 列表內元素限制產生
arr2 = [x for x in arr1 if x % 2 == 0]
# 列表內元素多重限制產生
arr3 = [x for x in arr1 if x >= 3 and x % 2]
# 巢狀列表元素產生
arr4 = [(x, y) for x in range(3) for y in range(4)]
print(arr1)
print(arr2)
print(arr3)
print(arr4)
2020年12月9日 星期三
SQL 一次insert 多筆
-- 傳統
insert into test.customer(pin,first_name,last_name) values(601,"Bush","Kim");
insert into test.customer(pin,first_name,last_name) values(602,"Grace","Kun");
insert into test.customer(pin,first_name,last_name) values(603,"Jully","LAin");
-- oracle
insert all
into test.customer(pin,first_name,last_name) values(601,"Bush","Kim")
into test.customer(pin,first_name,last_name) values(602,"Grace","Kun")
into test.customer(pin,first_name,last_name) values(603,"Jully","LAin");
-- mysql
insert into customer(pin,first_name,last_name)
values(601,"Bush","Kim"),
(602,"Grace","Kun"),
(603,"Jully","LAin");
2020年11月4日 星期三
Python 的日期字串格式摘要:
Python's strftime directives
| Code | Meaning | Example |
|---|---|---|
%a |
Weekday as locale’s abbreviated name. | Mon |
%A |
Weekday as locale’s full name. | Monday |
%w |
Weekday as a decimal number, where 0 is Sunday and 6 is Saturday. | 1 |
%d |
Day of the month as a zero-padded decimal number. | 30 |
%-d |
Day of the month as a decimal number. (Platform specific) | 30 |
%b |
Month as locale’s abbreviated name. | Sep |
%B |
Month as locale’s full name. | September |
%m |
Month as a zero-padded decimal number. | 09 |
%-m |
Month as a decimal number. (Platform specific) | 9 |
%y |
Year without century as a zero-padded decimal number. | 13 |
%Y |
Year with century as a decimal number. | 2013 |
%H |
Hour (24-hour clock) as a zero-padded decimal number. | 07 |
%-H |
Hour (24-hour clock) as a decimal number. (Platform specific) | 7 |
%I |
Hour (12-hour clock) as a zero-padded decimal number. | 07 |
%-I |
Hour (12-hour clock) as a decimal number. (Platform specific) | 7 |
%p |
Locale’s equivalent of either AM or PM. | AM |
%M |
Minute as a zero-padded decimal number. | 06 |
%-M |
Minute as a decimal number. (Platform specific) | 6 |
%S |
Second as a zero-padded decimal number. | 05 |
%-S |
Second as a decimal number. (Platform specific) | 5 |
%f |
Microsecond as a decimal number, zero-padded on the left. | 000000 |
%z |
UTC offset in the form +HHMM or -HHMM (empty string if the the object is naive). | |
%Z |
Time zone name (empty string if the object is naive). | |
%j |
Day of the year as a zero-padded decimal number. | 273 |
%-j |
Day of the year as a decimal number. (Platform specific) | 273 |
%U |
Week number of the year (Sunday as the first day of the week) as a zero padded decimal number. All days in a new year preceding the first Sunday are considered to be in week 0. | 39 |
%W |
Week number of the year (Monday as the first day of the week) as a decimal number. All days in a new year preceding the first Monday are considered to be in week 0. | 39 |
%c |
Locale’s appropriate date and time representation. | Mon Sep 30 07:06:05 2013 |
%x |
Locale’s appropriate date representation. | 09/30/13 |
%X |
Locale’s appropriate time representation. | 07:06:05 |
%% | A literal '%' character. | % |
2020年10月16日 星期五
Python令人混淆的底線命名
_name:
class 中的成員變數的變數名稱前有一底線,代表預計標示為是class內部用(非強制性)
module內定義的方法名稱前有一底線,代表不公開,需使用FQN可使用
也可改寫__all__()表示出外界使用
還有如果直接讓module於python的shell執行也會顯示使用
name_:變數名稱後有一底線,只是為解決關鍵字衝突
_ _name:
class 中的成員變數的變數名稱前有二底線,代表會在前加上一底線及一class名稱改寫,呈現給外部使用
但class內部使用依舊使用無改寫原名稱
反向植入成員變數,如命名規則一底線及一class名稱再加二底線的變數名,例"_ClassName_ _VarName"
後來出現這Class名稱的class定義,雖內部無此變數,但會自動加入
_ConfuseClass__confuseVar1=45
class ConfuseClass:
def testFun(self):
return __confuseVar1
ConfuseClass().testFun()
_ _name_ _:
代表python內class的特殊成員(不好的用法)如__init__()
_ :在python command shell 中代表最後一個物件,可能是一個值或list等
2019年2月13日 星期三
2014年6月12日 星期四
window client 無法synch LINUX NTPD
無法同步時間,window 再重啟也無效,最後使用以下方式(在CMD下),恢復正常
C:\>net time /setsntp:192.168.1.1
The command completed successfully.
C:\>net time /querysntp
The current SNTP value is: 192.168.1.1
The command completed successfully.
C:\>net stop w32time && net start w32time
The Windows Time service is stopping.
The Windows Time service was stopped successfully.
The Windows Time service is starting.
The Windows Time service was started successfully.