变量常量print

翻译:
known case of builtins。内建函数,自带函数。
Return the tuple (x//y, x%y) 返回元组 tuple.
Invariant.不变的。
Decimal。十进制
arguments。参数

知识点:
字符串格式化–>%s,%d,%f %号相当于占位符,s,d,f相当于指定类型为str,digit,float
print(“我叫%s 今年%d岁”%(‘json’,18))
变量:小写。a = 3.14159265359
常量:大写。PI = 3.14159265359python无限制,可更改。
函数
def print(self, *args, sep=’ ‘, end=’\n’, file=None): # known special case of print
“”"
print(value, …, sep=’ ‘, end=’\n’, file=sys.stdout, flush=False)

Prints the values to a stream, or to sys.stdout by default.
Optional keyword arguments:
file:  a file-like object (stream); defaults to the current sys.stdout.
sep:   string inserted between values, default a space.
end:   string appended after the last value, default a newline.
flush: whether to forcibly flush the stream.
"""

a = divmod(10, 3)
print(a)

输出
(3, 1)

def divmod(x, y): # known case of builtins.divmod
“”" Return the tuple (x//y, x%y). Invariant: div*y + mod == x. “”"
return (0, 0)

class Decimal(object):
“”“Floating point class for decimal arithmetic.”""

__slots__ = ('_exp','_int','_sign', '_is_special')
# Generally, the value of the Decimal instance is given by
#  (-1)**_sign * _int * 10**_exp
# Special values are signified by _is_special == True

# We're immutable, so use __new__ not __init__
def __new__(cls, value="0", context=None):
    """Create a decimal point instance.

    >>> Decimal('3.14')              # string input
    Decimal('3.14')
    >>> Decimal((0, (3, 1, 4), -2))  # tuple (sign, digit_tuple, exponent)
    Decimal('3.14')
    >>> Decimal(314)                 # int
    Decimal('314')
    >>> Decimal(Decimal(314))        # another decimal instance
    Decimal('314')
    >>> Decimal('  3.14  \\n')        # leading and trailing whitespace okay
    Decimal('3.14')
    """

import xxx,from xxx import yyy
两种导入模块的方式,一种是import xxx,另一种是from xxx import yyy,第一种仅仅导入一个模块,并且将该模块执行了一遍,if main =="main"里面的没有执行。
同时,有在当前的命名空间中导入变量,需要通过xxx.yyy的方式使用导入模块中的变量、函数、类等;
第二种则将模块中的变量yyy导入了当前命名空间,因此使用时可以直接以yyy调用,使用这种导入方法时,需要注意当前的命名空间是否有重名的,from xxx import *这种方式尽量不要使用,因为这样就破坏了对命名空间的管理。

数据类型
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值