Mac OS X 配置指南

Mac OS X 配置指南

  • Docs
  • Blog

notes/python

Python

很久不用这门语言了,发现很多东西都忘记了。

复习一下 python 的一些细节上的 Syntax:

Comment syntax

有两种:

"""
This is the comment
"""

或者

# This is the comment

Build_in_function

内建函数指的是 __func__ 这样的函数。

以区别于:__func 以及 _func 。

关于内建函数可以参考:http://stackoverflow.com/questions/8689964/python-why-do-some-functions-have-underscores-before-and-after-the-functio

ps.我有时候都在想,如果没有 stackoverflow 的话,是不是世界上的程序员会少一半?

Math

a = 2**4 # Exponential
print a # 16

spam = 5%2 # Modulo
print spam # 1

Formatted output

python 里面也可以有 formatted output:

total = 54.6293125
print("%.2f" % total) # 54.63

String常用函数

len() 
str.upper() 
str.lower()

class

Variable length Input

using *args.

Cheatsheat

a = [1,2,3]
a[3:] = [1,2,3]
a = [1,2,3,4,5,6]
Last updated on 2019-1-8 by wild-flame
  • Comment syntax
  • Build_in_function
  • Math
  • Formatted output
  • String常用函数
  • class
  • Variable length Input
  • Cheatsheat
Docs
Mac OS 配置指南 | Mac OS Setup Guide乱七八糟的笔记
Projects
Leetcode solutionsJekyll simple猪瘟疫情可视化
More
BlogGitHub
Copyright © 2019 wild-flame