Date
Dec. 11th, 2024
 
2024年 11月 11日

Post: Python Cheatsheet

Python Cheatsheet

Published 08:08 Aug 02, 2020.

Created by @ezra. Categorized in #Programming, and tagged as #Cheatsheet.

Source format: Markdown

Table of Content

Python cheatsheet

Basics

Advanced

# With *args you can pass on parameters 
# with already defined values
def myFun(*argv):
    for arg in argv:
        print (arg)

myFun('Hello', 'Welcome', 'to', 'GeeksforGeeks')


# with **kwargs you can add keyworded, variable-length 
# argument list as a paramter to a function
# One can think of the kwargs as being a dictionary that maps 
# each keyword to the value that we pass alongside it
def myFun(**kwargs):
    for key, value in kwargs.items():
        print ("%s == %s" %(key, value))

myFun(first ='Geeks', mid ='for', last='Geeks')  


# You can also combine args and kwargs together inside a paramter
def myFun(*args,**kwargs):
    print("args: ", args)
    print("kwargs: ", kwargs)

myFun('geeks','for','geeks',first="Geeks",mid="for",last="Geeks")

Python Folder Structure

-README -- basic readme - config.py -- if you have configs - requirements.txt -- for pip dependencies - venv/ -- for virtualenv - /scripts -- for that kind of command-line interface stuff - /tests -- for your tests - /lib -- for your C-language libraries - /doc -- for most documentation - /apidoc -- for the Epydoc-generated API docs. - /appname or /src -- that has the main project code

Pinned Message
HOTODOGO
The Founder and CEO of Infeca Technology.
Developer, Designer, Blogger.
Big fan of Apple, Love of colour.
Feel free to contact me.
反曲点科技创始人和首席执行官。
开发、设计与写作皆为所长。
热爱苹果、钟情色彩。
随时恭候 垂询