多语言展示
当前在线:204今日阅读:168今日分享:49

如何运用JUPYTER NOTEBOOK的问号

运用JUPYTER NOTEBOOK的问号
工具/原料

JUPYTER NOTEBOOK

方法/步骤
1

打开JUPYTER NOTEBOOK,新建一个空白的PY文档。

2

a = [2, 999, 3232]a?Type:        listString form: [2, 999, 3232]Length:      3Docstring:  list() -> new empty list list(iterable) -> new list initialized from iterable's items定义一个列表,列表加上问号,可以查看这个列表的详情。

3

?a如果把问号放在前面也是一样的,根据个人习惯定义即可。

4

print?Docstring: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.Type:      builtin_function_or_methodprint是自带的function,也是可以用?查看用法。

5

def plus(x, y):    'plus 2 numbers together'    return x * yplus?Signature: plus(x, y)Docstring: plus 2 numbers togetherFile:      c:\users\danson\desktop\Type:      function定义一个函数,也是可以查看该函数的信息。

6

plus??Signature: plus(x, y)Source:   def plus(x, y):    'plus 2 numbers together'    return x * yFile:      c:\users\danson\desktop\Type:      function如果要更具体的信息,可以加两个问号,对于长篇的编程来看,也是非常方便就可以查看函数的。

7

oo = {'a': 332, 'b': 32423, 'c':1231}oo?Type:        dictString form: {'a': 332, 'b': 32423, 'c': 1231}Length:      3Docstring:  dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's    (key, value) pairs dict(iterable) -> new dictionary initialized as if via:    d = {}    for k, v in iterable:        d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs    in the keyword argument list.  For example:  dict(one=1, two=2)字典和列表一样,也是可以查看调用的。

8

pp = (3, 1, 5, 0)pp?Type:        tupleString form: (3, 1, 5, 0)Length:      4Docstring:  tuple() -> empty tuple tuple(iterable) -> tuple initialized from iterable's items If the argument is a tuple, the return value is the same object.数组当然和列表和字典是一样可以这么操作查看的。

注意事项

注意单个和双个问号的区别

推荐信息