Python list[] dictionary{key: value},如何從兩個list,建立一個dictionary? by 儲蓄保險王 · 2022-09-04 prod = [“17 LCD”, “32吋電視”] pric = [10000, 20000] dic = {} key = “” for k in range(len(prod)): key = prod[k] dic[key] = pric[k] print(dic) 相關文章Python: pandas.read_excel(r"路徑\檔名.副檔名", header = None), 自動加上0,1...的欄標籤, DataFrame如何取某一直欄或橫列? 如何用 .iloc[bool_list] 取出判斷式為真的那一列? bool_list = list( df[0] == 0 ) ; bool_list = list(df[0].isin([0])) ; DataFrame如何顯示完整的資料? pandas.set_option ( "display.max_rows", None)Python物件導向(Object-oriented programming,簡稱OOP),類別(Class), 物件(Object), 屬性(Attribute)=變數, 方法(Method)=函式, 建構式(Constructor) def __init__(self,x,y): 計算計程車車資, assert 斷言, 全域變數與區域變數Python: Visual Studio Code如何強制終止程式?終端機位置,滑鼠右鍵 > Stop Code Run (快捷鍵: Ctrl + Alt + M)Python TQC考題: 輸入一個正整數n,並讀取read.txt內容,將首n列的每個英文字首字大寫輸出write.txt ; pandas.Series.str.title() #輸出csv或xlsx時,如何不輸出index 跟 header ? .to_csv( "write.txt", index=False, header=False)Linux / Unix 指令: ps aux | grep XXX.py ; ifconfig ("interface configuration"); ip addr ; hostname -I查詢ip addressPython:用numpy.polyfit()與numpy.poly1d()做多項式曲線擬和; matplotlib 如何變更legend圖例字型大小? plt.rc("legend", fontsize=16) ; ax.legend(loc = “best”, fontsize=16, handlelength=0.5, frameon = False)Python .encode() 字符串編碼與轉換,ord()函數求得chr的ASCII碼,struct.pack()Python如何讀取csv逗點分隔檔(每列內容為現金流),計算香港保單富衛人壽(FWD)盈聚優裕(UFE1)IRR,免費下載IRR計算機Python讀取csv逗點分隔檔: pandas.read_csv(r"路徑\檔名.副檔名") vs csv.reader(io.TextIOWrapper) 有何差別? 為何出現ParserError? #Parser:解析器,如何讀取Excel檔(xlsx)?pandas.read_excel()
0 Python: numpy 4d array如何取值? pandas如何去掉空列/空欄? 如何重置DataFrame的index/欄標籤? df_drop = df_Raw.dropna (axis=0, how=”all”).reset_index(drop=True) ; df_drop1.columns = list(range(df_drop1.columns.size)) 2022-12-22
0 Python: 若符合特定條件或觸發AssertionError, 如何提前終止函式?將return置於if, elif, except AssertionError的縮排之下 2023-06-17
0 Python TQC考題802 字元對應,ASCII碼ord(), chr(), list(str)會把字串的每一個字母拆分進入list中,string跟list都可以使用index定位,沒有非要將string轉為list, for i in str: i 也可以依序代入str的每一個chr 2022-05-01
近期留言