In [18]: b
Out[18]: [1, 2, 3]
In [19]: b?
Type: list
String form: [1, 2, 3]
Length: 3
Docstring:
list() -> new empty list
list(iterable) -> new list initialized from iterable's items
In [24]: import datetime
In [26]: datetime.d*?
datetime.date
datetime.datetime
datetime.datetime_CAPI
In [20]: def aa():
...: return 1 + 2
In [23]: aa??
Signature: aa()
Source:
def aa():
return 1 + 2
File: c:\users\administrator\<ipython-input-20-1dd770e0920c>
Type: function
%run :执行文件
%run my_test.py
粘贴代码
1. Ctrl-Shift-V
2. %paste
3. %cpaste
In [3]: cpaste
Pasting code; enter '--' alone on the line to stop or use Ctrl-D.
:print(22)
:--
22
%time :一次执行一条语句,报告总体执行时间
%timeit :执行多次,产生平均执行时间
In [4]: strings = ['foo', 'foobar', 'sdf', 'eee'] * 100000
In [6]: %time method1 = [x for x in strings if x.startswith('foo')]
Wall time: 155 ms
In [7]: %timeit method1 = [x for x in strings if x.startswith('foo')]
10 loops, best of 3: 142 ms per loop
In [18]: bOut[18]: [1, 2, 3]In [19]: b?Type: listString form: [1, 2, 3]Length: 3Docstring:list() -&amp;gt; new empty listlist(iterable) -&amp;gt; new list initialized from iterable's items