ipython 学习笔记 1 基础
2015-06-03 12:03
666 查看
ref: Learning Ipython for interactive computing and data visualization
code website: http://ipython.rossant.net.
启动:
基础,可以用powershell在window下实现近似linux操作
notepad.exe 可代替vi啦
在shell下ipython notebook 可以启动notebook
chrome里输入http://localhost:8888/tree
就是我的notebook地址
一些简单指令:
Quick benchmarking with the %timeit command
Quick debugging with the %debug command
to make the plot work
Hot Keys
• Press the Enter key to create a new line in the cell and not execute the cell
• Press Shift + Enter to execute the cell and go to the next cell
• Press Alt + Enter to execute the cell and append a new empty cell right after it
• Press Ctrl + Enter for quick instant experiments when you do not want to
save the output
• Press Ctrl + M and then the H key to display the list of all the keyboard
shortcuts
Chapter 2
for python 3.4
bookmark a folder's path
lambda function
very cool interperation about this egos.py script
cmd line is:
"
Here is an explanation of what the last line does. The lambda function takes a filename as an argument following the template <egoid>.<extension>, and returns the egoid ID as an integer. It uses the split method of any string, which splits a string with a given character and returns a list of substrings, which are separated by this character. Here, the first element of the list is the <egoid> part. The map built-in Python function applies this lambda function to all filenames. The set function converts this list to a set object, thereby removing all duplicates and keeping only a list of unique identifiers (since any identifier appears twice with two different extensions). Finally, the sorted function converts the set object to a list, and sorts it in an increasing order.
"
debug
code website: http://ipython.rossant.net.
启动:
基础,可以用powershell在window下实现近似linux操作
notepad.exe 可代替vi啦
在shell下ipython notebook 可以启动notebook
chrome里输入http://localhost:8888/tree
就是我的notebook地址
一些简单指令:
Quick benchmarking with the %timeit command
%timeit [x*x for x in range(100000)]
Quick debugging with the %debug command
to make the plot work
%matplotlib inline
Hot Keys
• Press the Enter key to create a new line in the cell and not execute the cell
• Press Shift + Enter to execute the cell and go to the next cell
• Press Alt + Enter to execute the cell and append a new empty cell right after it
• Press Ctrl + Enter for quick instant experiments when you do not want to
save the output
• Press Ctrl + M and then the H key to display the list of all the keyboard
shortcuts
Chapter 2
for python 3.4
from urllib.request import urlopen html = 'http://ipython.rossant.net/' filename = 'facebook.zip' downloaded=urllib.request.urlopen(html+filename) with open(filename, 'wb') as f: f.write(download.read()) with zipfile.ZipFile(filename) as zip:zip.extractall('.')
bookmark a folder's path
%bookmark fbdata then cd fbdata
lambda function
import sys import os # we retrieve the folder as the first positional argument # to the command-line call if len(sys.argv) > 1: folder = sys.argv[1] # we list all files in the specified folder files = os.listdir(folder) # ids contains the sorted list of all unique idenfitiers ids = sorted(set(map(lambda file: int(file.split('.')[0]), files)))
very cool interperation about this egos.py script
cmd line is:
%run egos.py facebook
"
Here is an explanation of what the last line does. The lambda function takes a filename as an argument following the template <egoid>.<extension>, and returns the egoid ID as an integer. It uses the split method of any string, which splits a string with a given character and returns a list of substrings, which are separated by this character. Here, the first element of the list is the <egoid> part. The map built-in Python function applies this lambda function to all filenames. The set function converts this list to a set object, thereby removing all duplicates and keeping only a list of unique identifiers (since any identifier appears twice with two different extensions). Finally, the sorted function converts the set object to a list, and sorts it in an increasing order.
"
debug
%run -d %pdb
相关文章推荐
- Python找出文件中使用率最高的汉字实例详解
- Python实现Windows上气泡提醒效果的方法
- 股票模拟买卖
- Python捕捉和模拟鼠标事件的方法
- Python while、for、生成器、列表推导等语句的执行效率测试
- windows下python安装Numpy、Scipy、matplotlib模块
- Python fileinput模块使用实例
- Python中的PIL
- 以windows service方式运行Python程序的方法
- Python集合(set)类型的操作
- 自己编程中遇到的Python错误和解决方法汇总整理
- python中list常用操作实例详解
- python中argparse模块用法实例详解
- Python中的推导式使用详解
- 对于Python装饰器使用的一些建议
- Python模块搜索概念介绍及模块安装方法介绍
- 从底层简析Python程序的执行过程
- python 日期转星期
- Python第四节FUNCTIONS学习汇总。
- 总结的几个Python函数方法设计原则