当前位置: 首页 > news >正文

网站制作详细过程网页版qq空间电脑版

网站制作详细过程,网页版qq空间电脑版,昆山专业网站建设,wordpress 模板 设置1.IPython 的帮助文档 使用 help() 使用 ? 使用 ?? tab 自动补全 shift tab 查看参数和函数说明 2.运行外部 Python 文件 使用下面命令运行外部 Python 文件(默认是当前目录,也可以使用绝对路径) %run *.py …

1.IPython 的帮助文档

  • 使用 help()

  • 使用 ?

  • 使用 ??

  • tab 自动补全

  • shift + tab 查看参数和函数说明

2.运行外部 Python 文件

  • 使用下面命令运行外部 Python 文件(默认是当前目录,也可以使用绝对路径)

%run *.py

示例:在当前目录下有一个 myscript.py 文件:

def square(x):   """square a number"""   return x ** 2for N in range(1,4):   print(N, "squared is", square(N))

可以通过下面命令执行:

%run myscript.py# 执行效果1 squared is 12 squared is 43 squared is 9

尤其要注意的是,当我们使用魔法命令执行了一个外部文件时,该文件的函数就能在当前会话中使用

  • 只输出最后一个

square(5)square(6)# 执行结果36
  • a,b只能写在最后一行,以元组输出

a = square(5)b = square(6)a,b# 执行结果(25, 36)
  • 换行分别输出

a = square(5)b = square(6)display(a,b)# 执行结果2536
  • 以打印的方式输出

a = square(5)b = square(6)print(a,b)# 执行结果25 36
  • 导入 myscript.py 文件

import myscript#执行效果1 squared is 12 squared is 43 squared is 9

3.运行计时

  • 用下面命令计算 statement 的运行时间

%time statement# %time:一般用来统计耗时较长代码的运行时长%time square(100)# 执行效果CPU times: total: 0 nsWall time: 0 nsOut[28]:10000
  • 用下面命令统计 statement 的平均运行时间

%timeit statement
  • timeit 会多次运行 statement,最后得到一个更为精准的预期运行时间

%timeit square(100)#执行效果209 ns ± 8.52 ns per loop (mean ± std. dev. of 7 runs, 1,000,000 loops each)%timeit -r 3 -n 100 square(100)#执行效果322 ns ± 45.9 ns per loop (mean ± std. dev. of 3 runs, 100 loops each)
  • 可以使用两个百分号来测试多行代码的平均运行时间

%%timeitsquare(100)add(10,20)# 执行效果344 ns ± 5.84 ns per loop (mean ± std. dev. of 7 runs, 1,000,000 loops each)
  • 记住

%time  # 一般用于耗时长的代码段%timeit  # 一般用于耗时短的代码段

4.查看当前会话中的所有变量与函数(了解)

  • 快速查看当前会话的所有变量与函数名称

%who# 执行效果N     a     add     b     myscript     numpy     square
  • 查看当前会话的所有变量与函数名称的详细信息

%whos# 执行效果Variable   Type        Data/Info--------------------------------N          int         3a          int         25add        function    <function add at 0x000001AD7CAEE0C0>b          int         36myscript   module      <module 'myscript' from '<...>top\\NumPy\\myscript.py'>numpy      module      <module 'numpy' from 'D:\<...>ges\\numpy\\__init__.py'>square     function    <function square at 0x000001AD7D8F9C60>
  • 返回一个字符串列表,里面元素时当前会话的所有变量与函数名称

%who_ls# 执行效果['N', 'a', 'add', 'b', 'myscript', 'numpy', 'square']

4.安装包

  • 使用 pip 命令安装

pip install numpy

5.更多魔法命令

  • 列出所有魔法命令

lsmagic# 执行效果Available line magics:%alias  %alias_magic  %autoawait  %autocall  %automagic  %autosave  %bookmark  %cd  %clear  %cls  %code_wrap  %colors  %conda  %config  %connect_info  %copy  %ddir  %debug  %dhist  %dirs  %doctest_mode  %echo  %ed  %edit  %env  %gui  %hist  %history  %killbgscripts  %ldir  %less  %load  %load_ext  %loadpy  %logoff  %logon  %logstart  %logstate  %logstop  %ls  %lsmagic  %macro  %magic  %matplotlib  %mkdir  %more  %notebook  %page  %pastebin  %pdb  %pdef  %pdoc  %pfile  %pinfo  %pinfo2  %pip  %popd  %pprint  %precision  %prun  %psearch  %psource  %pushd  %pwd  %pycat  %pylab  %qtconsole  %quickref  %recall  %rehashx  %reload_ext  %ren  %rep  %rerun  %reset  %reset_selective  %rmdir  %run  %save  %sc  %set_env  %store  %sx  %system  %tb  %time  %timeit  %unalias  %unload_ext  %who  %who_ls  %whos  %xdel  %xmodeAvailable cell magics:%%!  %%HTML  %%SVG  %%bash  %%capture  %%cmd  %%code_wrap  %%debug  %%file  %%html  %%javascript  %%js  %%latex  %%markdown  %%perl  %%prun  %%pypy  %%python  %%python2  %%python3  %%ruby  %%script  %%sh  %%svg  %%sx  %%system  %%time  %%timeit  %%writefileAutomagic is ON, % prefix IS NOT needed for line magics.
  • 查看魔法命令的文档:使用?

# 例如查看魔法命令 %run 的文档%run?

http://www.sczhlp.com/news/100389/

相关文章:

  • 2025/09/14 【二叉树11】完全二叉树的节点个数
  • 8888
  • 接口限流代码 - 实践
  • 网站导航颜色榆林免费做网站
  • 成都58手机微信网站建设名录wordpress 自定义page
  • 企业网站运营推广提供手机网站怎么做
  • 深圳网站建设九曲网域名到网站上线
  • 搭建网站的流程微信网站 详解
  • 启用中文域名大网站太子河网站建设
  • 网站翻页wordpress网站背景设置
  • OutGuess 安装与问题排查指南(Kali Linux 环境)
  • 拓展操作码举例
  • TryHackMe | Cicada-3301 Vol:1
  • 计算机网站建设职业群宣讲家网站官网加强作风建设
  • 苏州模板建站定制演示网站怎么做
  • 海外社交网站开发apache 安装 wordpress
  • 万网域名绑定到其它网站网站建设与规划论文
  • 万业网网站建设审核河口区建设工程招标网站
  • 小额贷网站建设中国中铁建设集团门户网登录
  • 上海建设工程 U盘登录哪个网站做书的网站有哪些内容
  • 响应式网站模板 开源沈阳大型网站设计公司
  • 网站建设的产品类型是什么山西太原建站哪家强
  • 网站制作公司排名前十从哪里找网络推广公司
  • 河北省建设机械协会官方网站国外网站如何建设
  • 完整教程:Word添加图/表题注
  • 网站建设工作的函wordpress 简洁
  • 西安电子商务网站建设网易网站建设
  • 广州网站建设开发汕头站扩建效果图
  • 可以做宣传的网站长沙建网
  • 织梦网站建设后优化步骤网站建设标准流程