python用float顯示list index out of range_Python學習的必備法寶,隨查隨用,太方便了吧!...
阿新 • • 發佈:2021-01-05
技術標籤:python用float顯示list index out of range
大多數的cheatsheet都是簡單的語法規則列表,如果你手頭有一份cheatsheet會讓你的工作效率大大提升。
近日,有一叫Python-cheatsheet專案在Hacker News、Reddit、Github等網站上成功引起了廣大程式設計師的注意。
Python-cheatsheet是一份超全的Python速查表,最大的特點就是你無需安裝和配置,線上就能使用,內容十分全面
Python資源共享群:484031800
目前,python-cheatsheet已經過在Github上獲得 7885
清單的開頭就對這份內容進行一個梳理,可以看出內容涵蓋: 容器、型別、語法、系統、資料、庫,以及Advanced Python等。 你只要點選相關知識點,就會跳轉到相關的詳情頁,下面以Main和List為例
Main
if __name__ == '__main__': # Runs main() if file wasn't imported. main() List
<list> = <list>[from_inclusive : to_exclusive : ±step_size] <list>.append(<el>) # Or: <list> += [<el>] <list>.extend(<collection>) # Or: <list> += <collection> <list>.sort() <list>.reverse() <list> = sorted(<collection>) <iter> = reversed(<list>) sum_of_elements = sum(<collection>) elementwise_sum = [sum(pair) for pair in zip(list_a, list_b)] sorted_by_second = sorted(<collection>, key=lambda el: el[1]) sorted_by_both = sorted(<collection>, key=lambda el: (el[1], el[0])) flatter_list = list(itertools.chain.from_iterable(<list>)) product_of_elems = functools.reduce(lambda out, x: out * x, <collection>) list_of_chars = list(<str>) index = <list>.index(<el>) # Returns index of first occurrence or raises ValueError. <list>.insert(index, <el>) # Inserts item at index and moves the rest to the right. <el> = <list>.pop([index]) # Removes and returns item at index or from the end. <list>.remove(<el>) # Removes first occurrence of item or raises ValueError. <list>.clear() # Removes all items. Also works on dict and set.
整份文件基本都是程式碼,只有個別內容會新增一些簡短的文字說明,對於用法建立者為了減少使用者的負擔,只給了最常見的用法,用最簡潔的方式給你最需要的用法
如果你不想線上使用該文件,你也可以下載文字,下載地址: https://raw.githubusercontent.com/gto76/python-cheatsheet/master/README.md