Please enable JavaScript.
Coggle requires JavaScript to display documents.
Python, 大數據處理, Excel, 型態type
type(4)-->int
type(4.4)-->float, 運算子,…
-
-
-
-
-
布林運算
3 == 4 Equality --> False
3 != 4 Inequality --> True
3 < 4 Smaller --> True
3 <= 4 Smaller or equal --> True
10 < 12 < 17 Chain logical expressions --> True
not True --> False "not"
False and True --> Flase "and"
False or True --> True "or"
檢查物件為T或F
bool(2) --> True
bool(0) --> False
bool("some text") --> True
bool("") --> False
bool(None) --> False
字串
"字串" + '字串'
\ 跳脫字元
f-string
字串與變數相加
first_adjective, second_adjective = "free", "open source"
f"Python is {first_adjective} and {second_adjective}."
--> Python is free and open source
-
-
批量創立excel文件
import xlwings as xw
app = xw.App(visible=Ture, add_book=False)
for dept in ["技術部", "銷售部", "營運部", "財務部"]
workbook = app.books.add()
workbook.save(f" ./部門業績-{dept}.xslx")
批量打開excel文件
import os
import xlwings as xw
app = xw.App(visible=Ture, add_book=False)
for file in os.listdir("."):
if file.endswith(".xlsx"):
app.books.open(file)
批量修改excel文件名稱
import os
import xlwings as xw
app = xw.App(visible=Ture, add_book=False)
for file in os.listdir("."):
if file.endswith(".xlsx"):
app.books.open(file)
-
-
變數儲存設定
name='張三'
phone='1234567890'
birthdate='1900/01/01'
money=100000
print('人名:{}電話:{}存款:{}'.format(name,phone,money))
-
型別
money=1000
name='張三'
PI=3.14159
print('money型別:{}name型別:{}PI型別:{}'format(type(money),type(name),type(PI)))
-
-
-
-
-
-
-
-
輸入input
name=input('輸入姓名')
money=input('薪水(美元)')
將變數轉成int
result=int(money)*30
print('姓名:{}薪水:{}'format(name,result))
-
-
-