Posts Python Bootcamp
Post
Cancel

Python Bootcamp

  • Compiled vs Interpreted
    • Compiled: Code -> Machine Code -> Ready to Execute
    • Interpreted: Code -> Ready to Execute -> Interpreted -> Machine Code
  • Steps to install Python in MacOS
    • Upgrade Xcode
    • xcode-select –install
    • Using Homebrew to install by visiting brew.sh
    • brew install python
  • How to use Virtual Env
  • How to debug in Python
  • How to use Open method
1
2
3
4
f = open('photo.jpg', 'r+')
jpgdata = f.read()
f.close()

This is not a good way. You’d better use with to Open a file

  • How to use *args and **kwargs
    • *args is used for non-keywords arguments

      1
      2
      3
      4
      5
      6
      
      def test_var_args(f_arg, *argv):
      print("first normal arg:", f_arg)
      for arg in argv:
          print("another arg through *argv:", arg)
      
      test_var_args('yasoob', 'python', 'eggs', 'test')
      
    • **kwargs is used for keywords arguments

      1
      2
      3
      4
      5
      6
      
      def greet_me(**kwargs):
      for key, value in kwargs.items():
          print("{0} = {1}".format(key, value))
      
      >>> greet_me(name="yasoob")
      name = yasoob
      
    • How to use regular expression

  • How to use Beautiful Soup 4 in Web Scraping

    1
    2
    3
    4
    5
    6
    
    from bs4 import BeautifulSoup
    
    with open("index.html", "r") as f:
      doc = BeautifulSoup(f, "html.parser")
      
    print(doc.prettify())
    

Resource

This post is licensed under CC BY 4.0 by the author.

Recent Update

    Trending Tags

    Contents

    Master The Theory Behind Programming

    2021年十二月份书单

    Trending Tags