整合營銷服務(wù)商

          電腦端+手機端+微信端=數(shù)據(jù)同步管理

          免費咨詢熱線:

          ipython常用方法說明

          ipython常用方法說明

          直苦于python蹩腳的IDE,最近尋覓到一個非常優(yōu)秀的python交互式解釋器ipython, 再此總結(jié)下實際中常用到的方法:

          特別說明下:本人為windows環(huán)境,所有命令都是相對windows的

          自動補全

          使用tab可以直接對已打出的對象或變量進行補全

          魔術(shù)關(guān)鍵字

          魔術(shù)關(guān)鍵字以%開頭,如果automagic打開了,則不用輸入%,否則需要,使用automagic可以切換狀態(tài)

          可以使用%magic參看所有魔術(shù)方法

          env 顯示環(huán)境變量

          ed或edit 編輯一個文件并執(zhí)行

          ed -x filename 編輯文件不執(zhí)行

          edit 3:10 編輯3:10行的指令并執(zhí)行

          hist 顯示歷史紀錄,可以用-n增加行號

          hist 3:10 顯示3-10行的歷史紀錄

          bg function 把function函數(shù)放到后臺執(zhí)行

          pwd 當(dāng)前目錄

          pycat filename 語法高亮顯示一個文件

          macro name 1:10 把1:10行的代碼設(shè)為name宏

          save filename 1:10 把1:10行代碼保存到文件中

          time statement 計算一段代碼執(zhí)行時間

          timeit statement 自動選擇重復(fù)和循環(huán)次數(shù)計算一段代碼執(zhí)行時間

          run filename 執(zhí)行一個文件,如果希望防止執(zhí)行的,需要增加if name==“main“:

          autoindent 如果啟用,粘貼的時候會自動縮進代碼

          reset 重置所有變量

          Bash命令

          cls 清除屏幕

          colors

          IPython -- An enhanced Interactive Python - Quick Reference Card================================================================obj?, obj?? : Get help, or more help for object (also works as ?obj, ??obj).
          ?foo.*abc* : List names in 'foo' containing 'abc' in them.
          %magic : Information about IPython's 'magic' % functions.
          Magic functions are prefixed by % or %%, and typically take their arguments
          without parentheses, quotes or even commas for convenience. Line magics take a
          single % and cell magics are prefixed with two %%.
          Example magic function calls:
          %alias d ls -F : 'd' is now an alias for 'ls -F'
          alias d ls -F : Works if 'alias' not a python name
          alist=%alias : Get list of aliases to 'alist'
          cd /usr/share : Obvious. cd -<tab> to choose from visited dirs.
          %cd?? : See help AND source for magic %cd
          %timeit x=10 : time the 'x=10' statement with high precision.
          %%timeit x=2**100
          x**100 : time 'x*100' with a setup of 'x=2**100'; setup code is not
           counted. This is an example of a cell magic.
          System commands:
          !cp a.txt b/ : System command escape, calls os.system()
          cp a.txt b/ : after %rehashx, most system commands work without !
          cp ${f}.txt $bar : Variable expansion in magics and system commands
          files=!ls /usr : Capture sytem command output
          files.s, files.l, files.n: "a b c", ['a','b','c'], 'a\nb\nc'
          History:
          _i, _ii, _iii : Previous, next previous, next next previous input
          _i4, _ih[2:5] : Input history line 4, lines 2-4
          exec _i81 : Execute input history line #81 again
          %rep 81 : Edit input history line #81
          _, __, ___ : previous, next previous, next next previous output
          _dh : Directory history
          _oh : Output history
          %hist : Command history. '%hist -g foo' search history for 'foo'
          Autocall:
          f 1,2 : f(1,2) # Off by default, enable with %autocall magic.
          /f 1,2 : f(1,2) (forced autoparen)
          ,f 1 2 : f("1","2")
          ;f 1 2 : f("1 2")
          Remember: TAB completion works in many contexts, not just file names
          or python names.
          The following magic functions are currently available:
          %alias:
           Define an alias for a system command.
          %alias_magic:
           %alias_magic [-l] [-c] name target
          %autocall:
           Make functions callable without having to type parentheses.
           #
          %automagic:
           Make magic functions callable without having to type the initial %.
           #使用%automagic on(off)打開(關(guān)閉)automagic,打開后使用魔術(shù)方法不需要加%
          %autosave:
           Set the autosave interval in the notebook (in seconds).
          %bookmark:
           Manage IPython's bookmark system.
          %cd:
           #切換目錄
           Change the current working directory.
          %clear:
           #清除終端
           Clear the terminal.
          %cls:
           Clear the terminal.
          %colors:
           Switch color scheme for prompts, info system and exception handlers.
           Currently implemented schemes: NoColor, Linux, LightBG.
           Color scheme names are not case-sensitive.
          %config:
           configure IPython
          %connect_info:
           Print information for connecting other clients to this kernel
          %debug:
           %debug [--breakpoint FILE:LINE] [statement [statement ...]]
          %dhist:
           Print your history of visited directories.
          %dirs:
           #返回當(dāng)前目錄
           Return the current directory stack.
          %doctest_mode:
           Toggle doctest mode on and off.
          %ed:
           #打開文本編輯器
           Alias for `%edit`.
          %edit:
           Bring up an editor and execute the resulting code.
          %env:
           #羅列環(huán)境變量
           List environment variables.
          %gui:
           Enable or disable IPython GUI event loop integration.
          %guiref:
           Show a basic reference about the GUI Console.
          %hist:
           Alias for `%history`.
          %history:
           %history [-n] [-o] [-p] [-t] [-f FILENAME] [-g [PATTERN [PATTERN ...]]]
          %install_default_config:
           %install_default_config has been deprecated.
          %install_ext:
           Download and install an extension from a URL, e.g.::
          %install_profiles:
           %install_profiles has been deprecated.
          %killbgscripts:
           Kill all BG processes started by %%script and its family.
          %less:
           Show a file through the pager.
          %load:
           #載入指定python文件的當(dāng)前源碼
           Load code into the current frontend.
          %load_ext:
           Load an IPython extension by its module name.
          %loadpy:
           Alias of `%load`
          %logoff:
           Temporarily stop logging.
          %logon:
           Restart logging.
          %logstart:
           Start logging anywhere in a session.
          %logstate:
           Print the status of the logging system.
          %logstop:
           Fully stop logging and close log file.
          %lsmagic:
           List currently available magic functions.
          %macro:
           Define a macro for future re-execution. It accepts ranges of history,
          %magic:
           Print information about the magic function system.
          %matplotlib:
           %matplotlib [gui]
          %more:
           Show a file through the pager.
          %notebook:
           %notebook [-e] [-f FORMAT] filename
          %page:
           Pretty print the object and display it through a pager.
          %pastebin:
           Upload code to Github's Gist paste bin, returning the URL.
          %pdb:
           Control the automatic calling of the pdb interactive debugger.
          %pdef:
           Print the call signature for any callable object.
          %pdoc:
           Print the docstring for an object.
          %pfile:
           Print (or run through pager) the file where an object is defined.
          %pinfo:
           Provide detailed information about an object.
          %pinfo2:
           Provide extra detailed information about an object.
          %popd:
           Change to directory popped off the top of the stack.
          %pprint:
           Toggle pretty printing on/off.
          %precision:
           Set floating point precision for pretty printing.
          %profile:
           Print your currently active IPython profile.
          %prun:
           Run a statement through the python code profiler.
          %psearch:
           Search for object in namespaces by wildcard.
          %psource:
           Print (or run through pager) the source code for an object.
          %pushd:
           Place the current dir on stack and change directory.
          %pwd:
           Return the current working directory path.
          %pycat:
           Show a syntax-highlighted file through a pager.
          %pylab:
           %pylab [--no-import-all] [gui]
          %qtconsole:
           Open a qtconsole connected to this kernel.
          %quickref:
           Show a quick reference sheet 
          %recall:
           Repeat a command, or get command to input line for editing.
          %rehashx:
           Update the alias table with all executable files in $PATH.
          %reload_ext:
           Reload an IPython extension by its module name.
          %rep:
           Alias for `%recall`.
          %rerun:
           Re-run previous input
          %reset:
           Resets the namespace by removing all names defined by the user, if
          %reset_selective:
           Resets the namespace by removing names defined by the user.
          %run:
           Run the named file inside IPython as a program.
          %save:
           Save a set of lines or a macro to a given filename.
          %sc:
           Shell capture - run shell command and capture output (DEPRECATED use !).
          %store:
           Lightweight persistence for python variables.
          %sx:
           Shell execute - run shell command and capture output (!! is short-hand).
          %system:
           Shell execute - run shell command and capture output (!! is short-hand).
          %tb:
           Print the last traceback with the currently active exception mode.
          %time:
           #一個python表達式的執(zhí)行時間
           Time execution of a Python statement or expression.
          %timeit:
           Time execution of a Python statement or expression
          %unalias:
           Remove an alias
          %unload_ext:
           Unload an IPython extension by its module name.
          %who:
           Print all interactive variables, with some minimal formatting.
          %who_ls:
           Return a sorted list of all interactive variables.
          %whos:
           Like %who, but gives some extra information about each variable.
          %xdel:
           Delete a variable, trying to clear it from anywhere that
          %xmode:
           Switch modes for the exception handlers.
          %%!:
           Shell execute - run shell command and capture output (!! is short-hand).
          %%HTML:
           Alias for `%%html`.
          %%SVG:
           Alias for `%%svg`.
          %%bash:
           %%bash script magic
          %%capture:
           %capture [--no-stderr] [--no-stdout] [output]
          %%cmd:
           %%cmd script magic
          %%debug:
           %debug [--breakpoint FILE:LINE] [statement [statement ...]]
          %%file:
           Alias for `%%writefile`.
          %%html:
           Render the cell as a block of HTML
          %%javascript:
           Run the cell block of Javascript code
          %%latex:
           Render the cell as a block of latex
          %%perl:
           %%perl script magic
          %%powershell:
           %%powershell script magic
          %%prun:
           Run a statement through the python code profiler.
          %%pypy:
           %%pypy script magic
          %%python:
           %%python script magic
          %%python3:
           %%python3 script magic
          %%ruby:
           %%ruby script magic
          %%script:
           %shebang [--proc PROC] [--bg] [--err ERR] [--out OUT]
          %%sh:
           %%sh script magic
          %%svg:
           Render the cell as an SVG literal
          %%sx:
           Shell execute - run shell command and capture output (!! is short-hand).
          %%system:
           Shell execute - run shell command and capture output (!! is short-hand).
          %%time:
           Time execution of a Python statement or expression.
          %%timeit:
           Time execution of a Python statement or expression
          %%writefile:
           %writefile [-a] filename
          1
          2
          3
          4
          5
          6
          7
          8
          9
          10
          11
          12
          13
          14
          15
          16
          17
          18
          19
          20
          21
          22
          23
          24
          25
          26
          27
          28
          29
          30
          31
          32
          33
          34
          35
          36
          37
          38
          39
          40
          41
          42
          43
          44
          45
          46
          47
          48
          49
          50
          51
          52
          53
          54
          55
          56
          57
          58
          59
          60
          61
          62
          63
          64
          65
          66
          67
          68
          69
          70
          71
          72
          73
          74
          75
          76
          77
          78
          79
          80
          81
          82
          83
          84
          85
          86
          87
          88
          89
          90
          91
          92
          93
          94
          95
          96
          97
          98
          99
          100
          101
          102
          103
          104
          105
          106
          107
          108
          109
          110
          111
          112
          113
          114
          115
          116
          117
          118
          119
          120
          121
          122
          123
          124
          125
          126
          127
          128
          129
          130
          131
          132
          133
          134
          135
          136
          137
          138
          139
          140
          141
          142
          143
          144
          145
          146
          147
          148
          149
          150
          151
          152
          153
          154
          155
          156
          157
          158
          159
          160
          161
          162
          163
          164
          165
          166
          167
          168
          169
          170
          171
          172
          173
          174
          175
          176
          177
          178
          179
          180
          181
          182
          183
          184
          185
          186
          187
          188
          189
          190
          191
          192
          193
          194
          195
          196
          197
          198
          199
          200
          201
          202
          203
          204
          205
          206
          207
          208
          209
          210
          211
          212
          213
          214
          215
          216
          217
          218
          219
          220
          221
          222
          223
          224
          225
          226
          227
          228
          229
          230
          231
          232
          233
          234
          235
          236
          237
          238
          239
          240
          241
          242
          243
          244
          245
          246
          247
          248
          249
          250
          251
          252
          253
          254
          255
          256
          257
          258
          259
          260
          261
          262
          263
          264
          265
          266
          267
          268
          269
          270
          271
          272
          273
          274
          275
          276
          277
          278
          279
          280
          281
          282
          283
          284
          285
          286
          287
          288
          289
          290
          291
          292
          

          使用!做前綴可以執(zhí)行shell命令,還可以用$來轉(zhuǎn)換python變量,如下

          for i in range(10):

          s=“dir%s” % i

          !mkdir $s

          for i in !ls:

          print i

          特別的,如果普通的shell命令有的話,必須使用

          的話,必須使用對原來的進行轉(zhuǎn)義,如果原來是echo

          進行轉(zhuǎn)義,如果原來是echoPATH,需要使用shell時候,需要寫成!echo $$PATH

          打印對象屬性

          使用dir可以將對象屬性打印出來,如

          import os

          dir(os)

          SP基本規(guī)范

          1. 頁面構(gòu)成

          JSP頁面頁面包含了模板元素和JSP元素,JSP元素由JSP引擎直接處理,必須符合JSP語法。JSP元素包括 的內(nèi)容:

          (1)腳本元素:聲明、腳本段、表達式。

          (2) 注釋:HTML注釋、Java注釋、JSP隱藏注釋。

          (3)指令元素:paga、include、taglib等。

          (4) 動作元素:jsp:include、jsp:forward等。

          在傳統(tǒng)的HTML頁面中加入Java程序片段就是和JSP標(biāo)簽就構(gòu)成了一個JSP頁面,其中Java程序片段由"<%"和"%>"作為開始和結(jié)束標(biāo)記。JSP腳本段內(nèi)定義的變量只在當(dāng)前頁面內(nèi)有效,屬于頁面內(nèi)的局部變量。

          下面用一個例子說明:

          在eclipse for JavaEE開發(fā)環(huán)境中新建一個項目,在webContent目錄上右擊,選擇JSP File,輸入文件名,創(chuàng)建一個JSP頁面

          在頁面中輸入下面的代碼

          <%@ page language="java" contentType="text/html; charset=UTF-8"

          pageEncoding="UTF-8"%>

          <%@ page import="java.util.*" %>

          <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

          <html>

          <head>

          <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

          <title>Insert title here</title>

          </head>

          <body>

          <%

          String name="王后";

          if(Calendar.getInstance().get(Calendar.AM_PM)==Calendar.AM) {

          out.println(name+",上午好!");

          }

          else {

          out.println(name+",下午好!");

          }

          int i=0;

          out.println("<br/>i的值為"+i);

          out.println("<br/>下面修改局部變量i的值");

          i++;

          out.println("<br/>修改好i的值為"+i);

          %>

          </body>

          </html>

          然后,在頁面上右擊選擇 Run AsRun on Server,可以在瀏覽器中看到運行效果

          2. 聲明

          在JSP頁面中,聲明是一段Java代碼,它用來定義JSP文件轉(zhuǎn)換后的Servlet文件中類的屬性和方法。聲明的屬性和方法在當(dāng)前JSP頁面的任何地方都可以使用,僅限當(dāng)前頁面。聲明的語法格式如下:

          <% !聲明1;聲明2;……%>

          下面的例子聲明一個方法visitor(),代碼如下:

          <%@ page language="java" contentType="text/html; charset=UTF-8"

          pageEncoding="UTF-8"%>

          <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

          <html>

          <head>

          <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

          <title>聲明的使用</title>

          </head>

          <body>

          <%! long i=0; %>

          <%! String name="紅桃"; %>

          <%! public String visitor(String who) {

          return "你好,"+who+"!";

          }

          %>

          <h2>

          <%

          i++;

          out.println(visitor(name));

          out.println("<br/>");

          out.print("你是本站第"+i+"為訪客");

          %>

          </h2>

          </body>

          </html>

          用同樣的方法運行,運行結(jié)果如下:

          由于聲明定義的變量i是頁面內(nèi)的全局變量,當(dāng)多次請求該JSP頁面時,i的值會被改變。當(dāng)我們刷新頁面幾次后

          3. 表達式

          表達式以<%=開始,%>結(jié)束,中間為一個合法的Java表達式。表達在JSP頁面被請求時計算,結(jié)果轉(zhuǎn)換為String類型字符串與其他模板數(shù)據(jù)淄河在一起。語法格式如下:

          <%=符合Java語法的表達式(結(jié)尾不帶分號)%>

          表達式開始符號<%=之間不能有任何空格。

          示例代碼如下:

          <%@ page language="java" contentType="text/html; charset=UTF-8"

          pageEncoding="UTF-8"%>

          <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

          <html>

          <head>

          <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

          <title>Insert title here</title>

          </head>

          <body>

          <%! long i=0;

          String name="紅桃";

          %>

          <%! public String visitor(String who) {

          return "你好,"+who+"!";

          }

          %>

          <h2>

          <%

          i++;

          %>

          <%=visitor(name) %><br/>//表達式使用

          你是本站第<%=i %>位訪客。//表達式使用

          </h2>

          </body>

          </html>

          執(zhí)行結(jié)果如下:

          第一部分先介紹到這里。

          多朋友想學(xué)一下網(wǎng)頁制作,上網(wǎng)一看,只要涉及到網(wǎng)頁制作,都離不開HTML這個詞語,HTML是HyperText Markup Language的簡稱,想學(xué)習(xí)HTML語言,先得了解一些基本知識,今天這邊內(nèi)容可以作為學(xué)習(xí)HTML的菜鳥教程第一課。

          HTML是什么?

          一般我們說HTML是指超文本標(biāo)記語言,英文名稱為HyperText Markup Language,簡稱HTML,它是目前互聯(lián)網(wǎng)上應(yīng)用最廣泛的語言。

          如何查看HTML?

          拿最常見的網(wǎng)頁為例,如果用大家熟悉的IE瀏覽器的話,直接在網(wǎng)頁上點右鍵,選擇“查看源”即可查看當(dāng)前網(wǎng)頁的HTML源碼;如果是其他瀏覽器的話,多數(shù)情況下點擊右鍵,選擇“查看源碼”或者類似“查看網(wǎng)頁源代碼”這樣的選項即可查看。

          當(dāng)然也可以通過專業(yè)的網(wǎng)頁制作軟件以及各種文本編輯器來查看。

          HTML有什么用?

          HTML語言可以方便地將網(wǎng)絡(luò)上存儲于不同位置的文字、圖片、聲音、視頻等內(nèi)容組織起來,方便用戶瀏覽。對于我們來說,HTML是學(xué)習(xí)網(wǎng)頁制作的基本功,熟練掌握HTML這項基本功,可以為以后的學(xué)習(xí)和工作打下良好的基礎(chǔ)。

          HTML如何入門?

          要學(xué)習(xí)任何編程語言,都不好好高騖遠,HTML的入門很簡單,但是也要遵循學(xué)習(xí)的基本步驟,選擇一本入門書籍,循序漸進地去學(xué)習(xí)每一張的內(nèi)容。一邊學(xué)習(xí),一邊查看網(wǎng)頁代碼對照來學(xué),提升入門速度。

          HTML案例

          下面就是最基本的HTML案例,在這個案例中,用的是HTML5,

          • <!DOCTYPE html> 聲明為 HTML5 文檔
          • <html> 元素是 HTML 頁面的根元素
          • <head> 元素包含了文檔的元(meta)數(shù)據(jù),如 <meta charset="utf-8"> 定義網(wǎng)頁編碼格式為 utf-8
          • <title> 描述了網(wǎng)頁的標(biāo)題
          • <body> 元素包含了可見的頁面內(nèi)容,因為下面是最簡單的案例,所以只有幾行,實際網(wǎng)頁一般都有很多行。
          • <h1> 定義一個大標(biāo)題
          • <p> 元素定義一個段落,也就是大家常說的分段。
          <!DOCTYPE html>
          <html>
          <head>
          <meta charset="utf-8">
          <title>HTML菜鳥教程(runoob.com)</title>
          </head>
          <body>
              <h1>我的第一個標(biāo)題</h1>
              <p>我的第一個段落。</p>
          </body>
          </html>

          如何編輯HTML?

          這個就很多了 ,比如最出名的Dreamweaver,當(dāng)然如果熟練之后,可以選擇任意自己喜歡的編輯器,一些小的改動或者一小段代碼的話,也可以用各種常見的文本編輯器來處理,比如我們在wodows系統(tǒng)上常見的記事本,總之只要自己覺得方便就好。

          總結(jié)

          以上是學(xué)習(xí)HTML菜鳥教程的第一課,首先保持一個良好的心態(tài)來學(xué)習(xí),有好的心態(tài),知識方面只要循序漸進,學(xué)會就是水到渠成的事情了 。


          主站蜘蛛池模板: 日本精品一区二区久久久| 日本一区二区不卡视频| 日韩精品电影一区亚洲| 无码喷水一区二区浪潮AV| 中文乱码字幕高清一区二区| 国产精品视频第一区二区三区| 亚洲乱码一区二区三区在线观看 | 久久99精品免费一区二区| 日本精品一区二区三区在线观看| 一区二区三区视频在线播放| 日韩AV无码一区二区三区不卡毛片| 久久免费国产精品一区二区| 一本大道东京热无码一区| 国产吧一区在线视频| 国产精品视频免费一区二区| 精品一区二区三区3d动漫| 亚洲色精品vr一区二区三区| 精品国产伦一区二区三区在线观看 | 久久精品国产亚洲一区二区三区| 国产一区视频在线| 麻豆精品人妻一区二区三区蜜桃| 无码AV动漫精品一区二区免费| 国产一区二区精品久久| 天美传媒一区二区三区| 秋霞午夜一区二区| 一区免费在线观看| 蜜臀AV在线播放一区二区三区| 狠狠综合久久av一区二区| 3d动漫精品成人一区二区三| 蜜桃视频一区二区| 中文字幕一区视频| 午夜福利一区二区三区高清视频 | 国产精品xxxx国产喷水亚洲国产精品无码久久一区 | 正在播放国产一区| 日韩内射美女人妻一区二区三区| 午夜视频久久久久一区 | 亚洲一区二区观看播放| 无码一区二区三区免费| 国产一区二区中文字幕| 韩国福利一区二区三区高清视频| 国产精品一区二区综合|