亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? python for newbies.htm

?? 1000 HOWTOs for various needs [WINDOWS]
?? HTM
?? 第 1 頁 / 共 4 頁
字號:


<HTML><HEAD><TITLE>Python for Newbies</TITLE>

<!--Style from http://blacksun.box.sk/tutorials.htm :)-->

<STYLE type=text/css>A:active {

	TEXT-DECORATION: none

}

A:hover {

	TEXT-DECORATION: underline

}

A:link {

	TEXT-DECORATION: none

}

A:visited {

	TEXT-DECORATION: none

}

</STYLE>



</HEAD>

<BODY aLink=#ccff00 bgColor=#000000 link=#99ccff text=#cccccc 

vLink=#cc99ff><FONT face="Verdana, Arial, Helvetica, sans-serif"><A name=top>

<H1 align=center>Python for Newbies</H1></A>

<H2 align=center>by <A href="mailto:skinite@home.com">Pupp3tM</A>, a.k.a. David 

Borowitz</H2>

<H3>Table of Contents</H3>

<OL>

  <LI><A 

  href="#intro">Introduction</A> 



  <OL type=a>

    <LI><A 

    href="#whatis">What 

    is Python?</A> 

    <LI><A 

    href="#interp">The 

    Interpreter</A> </LI></OL>

  <LI><A 

  href="#first">Your 

  First Program</A> 

  <OL type=a>

    <LI><A 

    href="#hello">Hello, 

    World!</A> 

    <LI><A 

    href="#explain">Explanation</A> 

    </LI></OL>

  <LI><A 

  href="#varmath">Variables 

  and Math</A> 

  <OL type=a>

    <LI><A 

    href="#var">Variables: 

    Strings, Numbers, etc.</A> 

    <LI><A 

    href="#math">Math 

    and Operators</A> </LI></OL>

  <LI><A 

  href="#io">Input/Output</A> 



  <OL type=a>

    <LI><A 

    href="#print">Printing 

    information</A> 

    <LI><A 

    href="#user">Interacting 

    with the User</A> </LI></OL>

  <LI><A 

  href="#control">Program 

  Control</A> 

  <OL type=a>

    <LI><A 

    href="#if">What 

    If...</A> 

    <LI><A 

    href="#for">For 

    Ever...</A> 

    <LI><A 

    href="#while">While 

    We...and Others</A> </LI></OL>

  <LI><A 

  href="#inter">Intermediate 

  Python</A> 

  <OL type=a>

    <LI><A 

    href="#tuples">Tuples!</A> 



    <LI><A 

    href="#string">Strings 

    and Slice Indexing</A> 

    <LI><A 

    href="#fileio">File 

    I/O</A> </LI></OL>

  <LI><A 

  href="#mod">Modules</A> 



  <OL type=a>

    <LI><A 

    href="#mod1">Overview 

    and Importing</A> 

    <LI><A 

    href="#builtin">Builtin 

    Modules</A> 

    <LI><A 

    href="#yours">User-Defined 

    Modules and Functions</A> </LI></OL>

  <LI><A 

  href="#close">In 

  Closing</A> 

  <OL type=a>

    <LI><A 

    href="#perl">Why 

    Python is Better than Perl</A> 

    <LI><A 

    href="#ref">References</A> 

    </LI></OL></LI></OL>

<HR>



<H2 align=center><A name=intro>Introduction</A></H2>

<H3 align=center><A name=whatis>What is Python?</A></H3><BR>

<P>Python is, in short, a scripting language. It is similar in function to Perl, 

but to my knowledge is not nearly as popular. To fix that is part of the goal of 

this tutorial. It is a very high-level language that can perform complex tasks, 

but is surprisingly easy to learn. Many different add=ons (modules) are 

available to control everything from MP3s to windowing toolkits (Unix). I find 

Python to be a just plain <I>fun</I> language to program in, as it is very 

intuitive and suited to a variety of uses. </P>

<P>Python can be run on almost any platform, from 'nix to Windows. To get 

Python, first go to <A href="http://www.python.org/">Python.org</A>, and then 

download away! </P>

<P>This tutorial is geared towards people who have little experience with 

programming but know at least something. I make numerous references to languages 

like C and Perl, which are good to know, but you won't lose much if you just 

skip over them. </P>

<P>What's with the funky name, you ask? Some sort of carnivorous reptile? No, 

dear reader. Python's creators were (are) big Monty Python fans. The name comes 

from the BBC show "Monty Python's Flying Circus," and in the official docs, it 

says "Making references to Monty Python skits in documentation is not only 

allowed, it is encouraged." That said, I'm afraid I haven't seen all too many 

Monty Python movies so we'll go a little light on the references :) </P>

<P>So sit back, grab a Coke, <A href="http://www.python.org/download/">download 

Python</A>, and get ready to learn :) </P>

<P><FONT size=-2><A 

href="#top">Back 

to top</A></FONT></P>

<HR>



<H3 align=center><A name=interp>The Interpreter</A></H3><BR>

<P>Python is a scripted, i.e. interpreted, language. Unlike C, which has a 

compiler, we have in Python the...(drum roll please)...Python interpreter. Once 

you have Python correctly installed, in your Unix shell or Dos box type 'python' 

(Note: anytime I tell you to type something and put it in quotes, don't type the 

quotes. I'm sure you already figured this out, but...). If you've used perl or 

some other interpreted language before, you might notice something: there's a 

prompt (those three little "&gt;&gt;&gt;" things)! Not waiting for stdin or 

saying "Usage: python &lt;script-file&gt;"! That's right, Python has an 

<I>interactive mode</I>. In this mode, you can type any Python command and it 

will work just like you typed it from a script, with a few differences. Most 

importantly, if you type a variable of some sort or something that returns a 

value of some sort (except assignments), it will print the result automatically. 

Neat for trying stuff out (and learning!). Now type '1 + 1' at the prompt you 

should still be at. What do you see? 2! Now ain't that a powerful language: <PRE>&gt;&gt;&gt; 1 + 1

2

</PRE>You can do this with any kind of variable or math expression (see part <A 

href="#math">3b</A>) 

and get some output. Works with strings too: <PRE>&gt;&gt;&gt; "elp! I'm being oppressed"

"elp! I'm being oppressed"

</PRE>Note the bad Monty Python reference :). Anyway, that's all for the 

interpreter. Now we get into the meat of things. If at any point there's a 

sample script and you don't feel like creating a new file for it, feel free to 

type (or better yet copy &amp; paste) it into the interpreter, it should work 

the same. Wait, scratch that :). If I put something in a script, it most likely 

means you only get the effect from a script and it won't work in interactive 

mode. Sorry. 

<P></P>

<P>Wait! One note before we leave. To quit the interpreter, you can't do 

anything fancy like type 'quit'. For some reason (beats me), that doesn't work. 

You have to type Ctrl+D to quit (on Unix at least, haven't tested it on 

Windows). Anyway if you type 'quit' it'll say something like 'Use Ctrl-D (i.e. 

EOF) to exit.' so listen to that. </P>

<P><FONT size=-2><A 

href="#top">Back 

to top</A></FONT></P>

<HR>



<H2 align=center><A name=first>Your First Program</A></H2>

<H3 align=center><A name=hello>Hello, World!</A></H3><BR>Alright, if you've ever 

read a programming tutorial before you know they all have some sort of program 

that just prints "Hello, World!" or something on the screen. Unfortunately, this 

tutorial is no different. Alright, here goes: <PRE>#!/usr/bin/python

#You only need the above line for Unix; replace that with your path to python



hello = "Hello, World!"

print hello

</PRE>That's it! Put that in a text file, name it hello.py, run it, and we're 

good. On Unix you may have to 'chmod +x hello.py' to run it, or just type 

'python hello.py'. Windows, I'm pretty sure .py files are associated with the 

Python interpreter automatically. 

<P></P>

<P><FONT size=-2><A 

href="#top">Back 

to top</A></FONT></P>

<HR>



<H3 align=center><A name=explain>Explanation</A></H3><BR>"Wow," you may be 

saying, "that was easy." Indeed it was. Now, though, you probably only have some 

remote clue of what's going on. We'll take it line by line. <PRE>#!/usr/bin/python

</PRE>This line, like you should've read, is only needed for Unix users. It 

tells your shell where the python executable is so it can run the script. <PRE>#You only need the above line for Unix; replace that with your path to python

</PRE>A pretty useless line, you may think, but it illustrates an important 

point: comments! Any good programmer knows that you need comments in your code, 

so just put # and anything after that on that line is a comment and will be 

ignored by the interpreter. <PRE>hello = "Hello, World!"

</PRE>I didn't really need this line, but I thought a Hello, World! script with 

only one line is kinda lame, so I added it anyway. hello is a string variable, 

which we'll talk about later, and the = operator assigns "Hello, World!" as its 

value. I'm sure if you've programmed before you've seen all this. <PRE>print hello

</PRE>This last line, as you may well guess, prints the contents of hello. If 

you're a perl guy (or girl :), you need to know that if you're printing a 

variable you can't put the name of the variable in quotes. But that's not too 

inconvenient, as we should see later. 

<P></P>

<P>Alright! Our first program! Now just a note or two before we move on. First, 

you may notice that there's nothing on the end of any lines, no ; like in perl 

or C. That's one of the convenient features of Python. I think it's more 

intuitive because blocks (later dammit!) are determined by indenting and every 

statement has its own line...you may disagree I guess but you'll just have to 

get used to it. </P>

<P><FONT size=-2><A 

href="#top">Back 

to top</A></FONT></P>

<HR>



<H2 align=center><A name=varmath>Variables and Math</A></H2>

<H3 align=center><A name=var>Variables: Strings, Numbers, etc.</A></H3><BR>In 

Python, just like any other language worth its salt, there are a number of data 

types, Mainly, there are numbers (of arbitrary precision), strings, lists, and 

tuples. Tuples are more of an "advanced" variable type, kind of like lists, so I 

won't go into them here, but I'll touch on them a bit in the <A 

href="#inter">Intermediate 

Python</A> section. 

<P></P>

<P>Numbers. What can I say? Numbers are numbers. To assign them, just like you 

did with the string in Hello World!, just put the name of your variable, the = 

operator, and what you want it to be: <PRE>&gt;&gt;&gt; a = 5

&gt;&gt;&gt;

</PRE>A word on variable names: I'm not quite sure exactly how long Python 

allows them to be (should I know?), but as a general rule you shouldn't have 

names more than 20 or so characters. Like other languages, variable names must 

be all alphanumeric characters and underscores (_), but you <I>can</I> start 

names with underscores, unlike some languages. 

<P></P>

<P>Anyway, on to strings. Strings store, obviously, strings of characters. 

Nothing you haven't heard before. For strings, you can use either type of quotes 

("" or ''), but be sure you know which kind. If you want to use, say, an 

apostrophe inside a string, you need to make sure of some things. If the string 

has "" quotes, don't worry about it, just put your apostraph. If you were in '' 

quotes, though, you would need to escape the apostrophe. This is so the 

interpreter doesn't think the apostrophe, which is just like a quote, is the end 

of your string. To escape the apostrophe, just put a \ (backslash) in front of 

the quote. Try it! It's great: <PRE>&gt;&gt;&gt; "I'm Dave"

"I'm Dave"

&gt;&gt;&gt; 'Python\'s my favorite language'

"Python's my favorite language"

&gt;&gt;&gt; "\"I can't think of anything else to say!\" he said"

'"I can\'t think of anything else to say!" he said'

&gt;&gt;&gt; 'That's too bad'

      File "&lt;stdin&gt;", line 1

    'That's too bad'

          ^

SyntaxError: invalid syntax

</PRE>Note the last two examples. The first one illustrates escaping of the "" 

quotes and also this: If you have both types of quotes in a string, Python will 

default to one and escape the other. Don't worry; if you're printing this to the 

screen it won't show the \ character in your output. In the last example, that's 

what happens when you don't escape quotes. You may notice Python has a nice way 

of handling errors, but we won't go into that. 

<P></P>

<P>Speaking of escaping, here are a few more characters you can escape (if it 

says 'n' then you use '\n' to escape it): 

<UL>

  <LI>n - Prints a newline, i.e. starts a new line. 

  <LI>t - Horizontal tab 

  <LI>b - Backslash. Deletes the last character typed 

  <LI>a - System beep 

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩精品一区二区在线| 91国偷自产一区二区开放时间| 欧美一区二区三区视频在线| 一区二区三区精密机械公司| 91啦中文在线观看| 亚洲免费在线视频一区 二区| 粉嫩av一区二区三区在线播放| 国产亚洲精品bt天堂精选| 国产成人免费视频一区| 国产精品每日更新| 一本色道久久综合亚洲精品按摩| 亚洲欧洲一区二区在线播放| 99久久久国产精品| 亚洲欧美福利一区二区| 欧美性xxxxxxxx| 美腿丝袜在线亚洲一区| 26uuu欧美日本| 成人av资源在线| 亚洲一卡二卡三卡四卡无卡久久| 欧美电影在哪看比较好| 久久99国产精品久久99果冻传媒| 久久久精品免费网站| 91影视在线播放| 亚洲成人激情社区| 精品一区二区三区蜜桃| 色综合色综合色综合色综合色综合| 国产亚洲短视频| 极品瑜伽女神91| 欧美性生活影院| 久久电影网站中文字幕| 94色蜜桃网一区二区三区| 国产一区二区三区香蕉 | 欧美日韩中文字幕精品| 日韩va亚洲va欧美va久久| 欧美大度的电影原声| 99精品欧美一区二区三区综合在线| 亚洲国产日韩av| 久久久久久久久蜜桃| www.色精品| 热久久一区二区| 欧美韩国日本不卡| 777亚洲妇女| 成年人国产精品| 三级影片在线观看欧美日韩一区二区| ww久久中文字幕| 在线精品视频免费播放| 国产suv精品一区二区6| 精品国产精品网麻豆系列| 国产在线看一区| 亚洲图片欧美一区| 亚洲国产精品av| 日韩视频免费观看高清完整版在线观看| 亚洲成人资源网| 国产欧美日韩精品在线| 欧美一区二区大片| 日本道在线观看一区二区| 国产激情偷乱视频一区二区三区| 亚洲国产三级在线| 亚洲天堂中文字幕| 久久久精品2019中文字幕之3| 欧美另类高清zo欧美| 99久久伊人网影院| 欧洲精品一区二区三区在线观看| 国产99精品国产| 国产女人水真多18毛片18精品视频| 精品视频一区二区不卡| 成人v精品蜜桃久久一区| 九九精品视频在线看| 五月天视频一区| 亚洲国产精品一区二区www | 国产日韩欧美精品一区| 777午夜精品免费视频| 欧美在线免费视屏| av在线播放不卡| 成人av网站在线| 岛国av在线一区| 国产精品1区2区3区在线观看| 毛片基地黄久久久久久天堂| 午夜精品久久久| 三级一区在线视频先锋| 午夜精品福利在线| 日韩电影在线一区二区| 天堂va蜜桃一区二区三区| 亚洲图片欧美视频| 亚洲成人免费在线观看| 亚洲成在人线在线播放| 亚洲v日本v欧美v久久精品| 亚洲午夜精品久久久久久久久| 亚洲一区在线观看视频| 在线视频一区二区三| 国产成人精品影院| 国产一区二区三区免费看| 国产精品电影一区二区| 日韩欧美一卡二卡| 欧美调教femdomvk| a级精品国产片在线观看| 五月婷婷综合在线| 亚洲色图视频网站| 国产亚洲污的网站| 亚洲精品一区在线观看| 日韩欧美一二三| 欧美电影免费观看高清完整版在线| av资源网一区| 波多野洁衣一区| 色综合天天综合给合国产| 黑人巨大精品欧美一区| 日韩av午夜在线观看| 亚洲一区二区三区四区在线| 亚洲国产高清不卡| 国产精品人人做人人爽人人添| 久久中文字幕电影| 国产精品久久久久久久久果冻传媒 | 国产高清视频一区| 免费观看成人av| 91视频www| 久久久久久久性| 性做久久久久久久免费看| 国产一区二区三区四区五区入口| 欧美日韩国产综合久久 | 中文字幕制服丝袜一区二区三区| 国产欧美日韩另类一区| 亚洲精品视频在线观看免费| 久久女同精品一区二区| www欧美成人18+| 日韩理论片在线| 国产91精品露脸国语对白| 亚洲一级二级三级| 亚洲手机成人高清视频| 国产一区二区福利视频| 在线看国产一区二区| 精品日韩在线观看| 成人黄色777网| 国产亚洲精品福利| 天天色图综合网| www.日韩av| 欧美精品一区二区在线观看| 一区二区三区精品视频在线| 国产综合久久久久久鬼色| 欧洲精品在线观看| 国产欧美日韩综合| 人人超碰91尤物精品国产| 色吧成人激情小说| 国产三级一区二区三区| 日韩国产精品久久久久久亚洲| www.欧美亚洲| 久久先锋资源网| 天堂在线一区二区| 色婷婷综合久久久| 中文字幕av不卡| 免费观看日韩电影| 欧美精品丝袜中出| 亚洲蜜臀av乱码久久精品| 国产91高潮流白浆在线麻豆 | 日韩精品色哟哟| 91亚洲大成网污www| 久久综合九色综合欧美亚洲| 日韩电影在线一区二区| 欧美色爱综合网| 亚洲人妖av一区二区| 国产成人在线视频网站| 2023国产精华国产精品| 日韩 欧美一区二区三区| 欧美日韩精品一区二区天天拍小说 | 秋霞影院一区二区| 欧美在线你懂的| 一区二区三区国产| 日本韩国精品在线| 亚洲乱码国产乱码精品精可以看| 国产99久久久国产精品潘金| 欧美精品一区二区三区一线天视频| 免费成人在线播放| 欧美一区在线视频| 男男gaygay亚洲| 日韩欧美一级二级| 久久福利视频一区二区| 欧美一区二区成人| 卡一卡二国产精品| 精品日韩在线一区| 国产一区二区三区精品视频| 精品久久久久一区| 国产在线精品不卡| 中文字幕乱码久久午夜不卡 | 欧美一区二区性放荡片| 爽好多水快深点欧美视频| 欧美一区二区三区人| 国产资源精品在线观看| 久久久久久久久久久电影| 国产精品自拍一区| 中文字幕一区二区三区在线观看 | 亚洲视频一二区| 色婷婷综合激情| 亚洲成a人片综合在线| 日韩欧美黄色影院| 国产在线精品一区二区不卡了| 久久久蜜臀国产一区二区| 91色视频在线| 视频一区视频二区中文字幕| 日韩三级视频中文字幕| 成人在线一区二区三区| 亚洲综合久久av|