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

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

?? python for newbies.htm

?? a collection of mega hacking tools
?? HTM
?? 第 1 頁 / 共 4 頁
字號:
  <LI>\ - Prints a backslash 

  <LI>r - Prints a carriage return. Use newline unless you know what you're 

  doing. </LI></UL>Of course there are more, but you won't use them too often. 

<P></P>

<P>With strings, you can also concatenate them (stick them together) with the + 

operator. If you have two literal strings (i.e. not functions that return a 

string), you don't even need an operator: <PRE>&gt;&gt;&gt; 'holy' + 'grail'

'holygrail'

&gt;&gt;&gt; 'BS' 'RF'

BSRF

</PRE>Next come lists. Lists are called arrays in some languages, but it's all 

the same (well, not quite...). A list is a bunch of values grouped together in 

brackets []. Lists can contain any number of other variables, even strings and 

numbers in the same list, but no tuples or nested lists. Assigning lists is 

simple: <PRE>&gt;&gt;&gt; a = [1, "thin", "mint", 0]

&gt;&gt;&gt; a

[1, 'thin', 'mint', 0]

</PRE>Lists can be accessed simply by name, but you can access any variable in a 

list with its index by putting the index number in brackets right after the 

name. Note that index numbering starts at 0: <PRE>&gt;&gt;&gt; a[0]

1

</PRE>You can also use negative index numbers to start counting from the end of 

the list: <PRE>&gt;&gt;&gt; a[-1]

0

</PRE>That's all for indexes for now, but in the Intermediate string section we 

get to learn about fun things like slice indexes to access more than one element 

in a list. You can also use your masterful index-calling knowledge in strings. 

Characters in a string act just like elements in a list: <PRE>&gt;&gt;&gt; a = "BSRF"

&gt;&gt;&gt; a[1]

S

</PRE>Be warned though: You can replace individual elements in a list, but not 

in a string: <PRE>&gt;&gt;&gt; a = [1, "thin", "mint", 0]

&gt;&gt;&gt; b = "BSRF"

&gt;&gt;&gt; a[3] = 4

&gt;&gt;&gt; a

[1, 'thin', 'mint', 4]

&gt;&gt;&gt; b[1] = "M"

Traceback (innermost last):

  File "&lt;stdin&gt;Traceback (innermost last):

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

TypeError: object doesn't support item assignment", line 1, in ?

</PRE>

<P></P>

<P>That's all folks! For data types at least... </P>

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

href="#top">Back 

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

<HR>



<H3 align=center><A name=math>Math and Operators</A></H3><BR>

<P>There are a few basic math operators in Python: +, -, *, /, **, and %. If you 

went to any school at all you know what +, -, *, and / do. That leaves ** and %. 

** is your exponentiatingneniating operator: <PRE>&gt;&gt;&gt; 2 ** 6

64

</PRE>Likewise % is your standard modulus operator. Modulus? Yeah. In case you 

don't know, the % operator divides the first number by the second number and 

gives the remainder. Observe: <PRE>&gt;&gt;&gt; 4 % 2

0

&gt;&gt;&gt; 10 % 3

1

&gt;&gt;&gt; 21 % 6

3

</PRE>You may have noticed in the course of trying out some of this stuff that 

if you divide, say, 1 by 3, you get 0. This is because Python always rounds down 

when working with integers. To work in floating-point numbers, just put a . 

(decimal point) in your expression somewhere: <PRE>&gt;&gt;&gt; #Bad

... 1/3

0

&gt;&gt;&gt; #Good

... 1./3

0.333333333333

&gt;&gt;&gt; #Good also

... 1/3.

0.333333333333

</PRE>In addition to your basic math operators, there are comparison operators 

in Python as well (what did you expect?). In the a couple more sections we'll 

learn how to use them in context, but here they are anyway: 

<UL>

  <LI>a == b checks if two a is equal to b (a and b can be any data type, not 

  just numbers) 

  <LI>a &gt; b checks if a is greater than b (see parentheses above) 

  <LI>a &lt; b checks if a is less than b (etc.) 

  <LI>a &gt;= b checks if a is greater than or equal to b 

  <LI>a &lt;= b checks if a is less than or equal to b 

  <LI>a != b checks if a isn't equal to b </LI></UL>You probably got nothing 

useful out of that except that even things like strings and lists can be 

compared. In fact, lists (or strings) don't even have to be of the same size to 

be compared: <PRE>&gt;&gt;&gt; #A return value of 1 means true, 0 means false

... [1, 2, 3, 4] &gt; [1, 2, 3]

1

&gt;&gt;&gt; [1, 2, 4] &gt; [1, 2, 3]

1

&gt;&gt;&gt; [1, 2, 3] &lt; [1, 3, 2]

1

&gt;&gt;&gt; [1, 2, -1] &gt; [1, 2]

1

</PRE>Also notice how list comparison is performed. The first values are 

compared. If they're equal, the next values are compared. If those two are 

equal, the next values are compared. This continues until the value in one is 

not equal to the value in the other (if all are equal then the lists are equal). 

Look at the third example: even though the 3rd value (index 2, remember) of the 

first list (3) is greater than the third of the second (2), the second list is 

still greater than the first because the interpreter never got that far; it 

found that the second number in the second list (3) was greater than in the 

first list (2), so it stopped (confused? That's Ok). If the interpreter gets to 

a null value (i.e. there are no items left in the list), then the longer list is 

greater (see 4th example above). 

<P></P>

<P>Last thing on operators: logical operators. and, or, not (there's no xor, 

unlike perl). and returns the last value encountered if true, 0 if false. or is 

the same, but it's true if only one of the arguments is non-zero (or non-null 

for strings). Finally, not returns 1 if the single argument is zero (null) or 0 

if the argument is non-zero. Observe: <PRE>&gt;&gt;&gt; 1 and 4

4

&gt;&gt;&gt; 2 or 0

2

&gt;&gt;&gt; 'monty' and 'python'

'python'

&gt;&gt;&gt; not 0

1

&gt;&gt;&gt; not ''

1

</PRE>

<P></P>

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

href="#top">Back 

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

<HR>



<H2 align=center><A name=io>Input/Output</A></H2>

<H3 align=center><A name=print>Printing information</A></H3>In our Hello, World! 

example above, we already saw one way of printing output, namely the 

(self-explanatory) print statement. print works pretty much like it does in 

perl, printing a string or any sort of variable or expression out on the screen. 

Anything you enter with print automatically has a newline, "\n", appended to it. 

<PRE>&gt;&gt;&gt; print "She's a witch!"

She's a witch!

&gt;&gt;&gt; print 5 + 3

8

&gt;&gt;&gt; a = "Burn her!"

&gt;&gt;&gt; print a

Burn her!

<A name=slice></A>&gt;&gt;&gt; #Don't worry if you don't know what this does; it's covered in the Intermediate section

... print "Yeah, b" + a[1:]

Yeah, burn her!

</PRE>If you don't want a newline appended, as is sometimes the case, simply add 

a ',' to the end of the line with your print statement. Note that this only 

works in non-interactive mode, so you need to make a new file.py or something. 

Try this on for size: <PRE>#!/usr/bin/python

a = 5

print "The value of a is",

print a,

print "!"

</PRE>Output: <PRE>The value of a is 5 !

</PRE>There's a few more ways you can put (non-string) variables in a print 

statement. You can use a comma, which will put a space around the variable. The 

final main way is to convert your variable to a string first, which is done 

simply by putting it in some backwards quotes (``). Then just append this to 

your string like you would any other string variable or value (see above). Check 

out these examples: <PRE>&gt;&gt;&gt; a=5

&gt;&gt;&gt; #Note the spacing around the number

... print "A duck costs $", a, "."

A duck costs $ 5 .

&gt;&gt;&gt; #Same thing, different way of putting it in

... print "A duck costs $" + `a` + "."

A duck costs $5.

</PRE>For those of you who know what stderr is (or stdout and stdin for that 

matter), yes, you can access it directly in Python. This does however use a bit 

more of an advanced technique, so to really understand what's going on here you 

should read <A 

href="#fileio">File 

I/O</A> and <A 

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

Anyway, try out this script: <PRE>#!/usr/bin/python



import sys #Didn't I tell you to read about modules?

sys.stderr.write( "This is some error text\n" ) #You do need a \n here since

#you're writing directly to the file descriptor (READ FILE I/O)

</PRE>Run it, it looks more or less normal, just prints "This is some error 

text". Now try running it as "python test.py &gt; /dev/null" (Unix) or "test.py 

&gt; nul" (Dos/Win). What's this? The output is still there, even though you 

redirected it to /dev/null or nul, the wastebasket of output. Instead of writing 

to the standard output (stdout), which is what print does, here you wrote to the 

standard error (stderr), which is separate from stdout (even though they appear 

on the same screen) and informs you of any errors your program might encounter. 

<P></P>

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

href="#top">Back 

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

<HR>



<H3 align=center><A name=user>Interacting with the User</H3>

<P>Alright, I admit it, this title is a bit too broad. In this section I'm just 

covering how to input variables from the user, not like catching keypresses or 

anything. Anyway, inputting from the, er, standard input is done with two simple 

functions in Python: input and raw_input. I'll discuss raw_input first 'cause 

it's simpler to use. </P>

<P>raw_input takes one argument, which is the prompt that'll come up while it 

waits for the user to type something. It returns the string that is typed, so it 

is most useful in assignments. A simple example: <PRE>&gt;&gt;&gt; a = raw_input( "Type something: " )

Type something: Dave

&gt;&gt;&gt; a

'Dave'

</PRE>Don't be too confused. I typed in 'Dave', and raw_input assigned it to the 

variable a. "That's all well and good," you say, "but what if I don't want to 

input a string? What if I want a number or list?" Well, there are really about 3 

ways. First and simplest is the input function, which you'll see if you just 

scroll down a bit. Another is string.atoi, which although a bit more advanced, 

adds some flexibility to the input process, although it only changes strings to 

ints (Subliminal message: <A 

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

I won't go into too much detail, but here's a simple example of atoi: <PRE>&gt;&gt;&gt; from string import atoi

&gt;&gt;&gt; a = "5"

&gt;&gt;&gt; a

'5'

&gt;&gt;&gt; a = atoi(a)

&gt;&gt;&gt; a

5

&gt;&gt;&gt; #If you have Python 2.0 or higher, just do this

... a = "5"

&gt;&gt;&gt; a = int(a)

&gt;&gt;&gt; a

5

</PRE>Wow, a was converted from '5' to 5. Now let's move on. If you want to 

input any type of variable at all, like I said before, you want to use input. 

Input works just like raw_input, except Python interprets the variables as 

whatever is typed in. If that didn't make much sense, think of it this way: If 

you have a straight-up number, it's stored as a number. If you have some values 

in [] brackets, it's stored as a list. You can even put something in quotes to 

have a string. Check it out: <PRE>&gt;&gt;&gt; a = input( "Enter something: " )

Enter something: 5

&gt;&gt;&gt; a

5

&gt;&gt;&gt; a = input( "Enter something: " )

Enter something: [3, 6, 'Hello']

&gt;&gt;&gt; a

[3, 6, 'Hello']

&gt;&gt;&gt; a = input( "Enter something: " )

Enter something: Hello

Traceback (most recent call last):

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

  File "&lt;string&gt;", line 0, in ?

NameError: There is no variable named 'Hello'

</PRE>Uh oh! What happened there? Well, the one pitfall of input is that it 

looks at everything as some sort of variable; it thought Hello was the name of a 

variable, so it screwed up when it found out there was no Hello. There are a few 

ways to get around this, like exception catching, but that's beyond the scope of 

this tutorial. For now, you'll have to trust your user to input the type of 

variable you want (I know, I know, you usually shouldn't trust your users, 

but...). Onward, onward. 

<P></P>

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

href="#top">Back 

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

<HR>



<H2 align=center><A name=control>Program Control</A></H2>

<H3 align=center><A name=if>What If...</A></H3>

<P>If you've <I>ever</I> programmed before, in something from Basic to Flash, 

you've seen if blocks. Hell, I don't even know why I devoted a whole section to 

them, since all I have to do is show you the structure, right? Alright, remember 

those comparison operators you used before? Good. Take a gander at this example 

code: <PRE>&gt;&gt;&gt; name = raw_input( "What's your name? " )

What's your name? David

&gt;&gt;&gt; if name &lt; "Dave":

...     print "Your name comes before mine." #That's a tab there

... elif name &gt; "Dave":

...     print "Your name comes after mine."

... else:

...     print "Hey, we have the same name!"

...

Your name comes after mine.

</PRE>Lame example, I know, but it gets the point across. Get over it. Now here 

you might notice a few things different than other languages you know (you might 

not, what can I say). We'll try to keep it in some sort of order too. First, you 

see the if, then a conditional statement. The conditional statement is just like 

we saw earlier, one expression and an operator and another expression. You could 

also just have an expression, and if'll see it as true if the expression 

evaluates to non-zero. But anyway. Next comes a colon, then a newline. You need 

this newline. On the next line or two or three or however many, the code is 

indented. One space, four spaces, eight spaces, it doesn't matter, it just has 

to be indented. Depending on how messy you generally code, this may be a 

convenient, code=beautifying feature or the code block from hell. I personally 

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产一区二区在线看| 日韩一区二区电影网| 成人精品免费视频| 国产一区二区成人久久免费影院| 麻豆成人91精品二区三区| 日韩精品欧美精品| 日韩av一区二| 免费久久99精品国产| 日韩av一级电影| 精品亚洲成a人在线观看 | 日韩精品色哟哟| 无码av中文一区二区三区桃花岛| 亚洲18影院在线观看| 免费视频一区二区| 久久精品国产亚洲高清剧情介绍| 精品中文字幕一区二区小辣椒| 另类欧美日韩国产在线| 国内欧美视频一区二区| 国产精品一区二区久激情瑜伽| 国产黄色精品网站| 92精品国产成人观看免费| 在线观看一区二区视频| 91精品国产美女浴室洗澡无遮挡| 精品久久久三级丝袜| 久久奇米777| 亚洲欧美日韩中文字幕一区二区三区| 亚洲一区在线播放| 蜜桃一区二区三区在线观看| 国产精品资源在线看| 不卡一区二区在线| 欧美视频一区在线| 欧美成人一区二区| 国产精品美女久久久久久| 亚洲黄色在线视频| 久久成人18免费观看| 成人动漫av在线| 欧美日韩久久不卡| 国产亚洲精品aa午夜观看| 国产精品二三区| 国产精品一区二区在线看| 99精品在线免费| 欧美一区二区在线视频| 国产亚洲精品资源在线26u| 亚洲综合一区二区| 国产在线一区观看| 欧洲一区在线电影| 26uuu亚洲| 亚洲激情av在线| 极品美女销魂一区二区三区免费| 99精品国产视频| 欧美成人女星排名| 夜夜操天天操亚洲| 国产一区二区成人久久免费影院| 日本韩国欧美国产| 国产午夜久久久久| 午夜日韩在线观看| 99精品视频在线观看免费| 欧美一区二区久久久| 亚洲婷婷在线视频| 久久www免费人成看片高清| 色欧美日韩亚洲| 久久精品这里都是精品| 五月天激情小说综合| av激情亚洲男人天堂| 日韩亚洲欧美一区| 亚洲免费三区一区二区| 国产高清一区日本| 欧美一级欧美一级在线播放| 亚洲色欲色欲www| 国产精品亚洲午夜一区二区三区| 3751色影院一区二区三区| 亚洲欧美偷拍另类a∨色屁股| 久久精品久久99精品久久| 欧美性大战xxxxx久久久| 国产精品美女久久久久久2018| 久久97超碰国产精品超碰| 欧美性视频一区二区三区| 亚洲乱码中文字幕综合| 欧美一激情一区二区三区| 亚洲宅男天堂在线观看无病毒| 国产精品99精品久久免费| 欧美一级片免费看| 午夜免费久久看| 91成人免费电影| 自拍偷拍亚洲激情| 不卡一二三区首页| 国产偷国产偷亚洲高清人白洁 | 北条麻妃一区二区三区| 精品久久久久久无| 日本欧美一区二区| 777亚洲妇女| 亚洲一区二区不卡免费| 色久综合一二码| 亚洲人成在线播放网站岛国| 不卡视频一二三四| 国产人伦精品一区二区| 国产精品亚洲第一区在线暖暖韩国 | 亚洲成人激情综合网| 91国产免费观看| 亚洲三级小视频| 91浏览器在线视频| 成人欧美一区二区三区黑人麻豆 | 中文字幕亚洲一区二区va在线| 国产一区二区三区高清播放| 精品国产一区a| 日韩av二区在线播放| 91麻豆精品国产91久久久资源速度 | 中文字幕在线观看不卡| 成人美女视频在线看| 国产精品电影一区二区| 97se狠狠狠综合亚洲狠狠| 国产精品国产三级国产普通话99| 99综合影院在线| 亚洲欧美在线视频| 一本色道久久综合精品竹菊| 一级精品视频在线观看宜春院| 欧美在线一二三四区| 香蕉影视欧美成人| 日韩亚洲欧美在线观看| 久久99精品国产91久久来源| 精品国产不卡一区二区三区| 国产精品一二三在| 中文字幕一区二区在线播放| 91亚洲资源网| 亚洲成人7777| 日韩一二三区视频| 国产v综合v亚洲欧| 亚洲欧美日韩中文字幕一区二区三区 | 成人激情视频网站| 亚洲伦理在线免费看| 在线电影院国产精品| 久久99精品国产.久久久久 | 一区二区三区免费在线观看| 欧美日韩国产综合一区二区| 美腿丝袜在线亚洲一区| 国产欧美1区2区3区| 色天天综合久久久久综合片| 午夜久久久久久久久久一区二区| 91精品免费在线观看| 国产精品一级二级三级| 一区二区三区在线免费视频| 制服丝袜国产精品| 丁香婷婷综合激情五月色| 亚洲午夜久久久久久久久电影网| 欧美一区二区私人影院日本| 粉嫩嫩av羞羞动漫久久久 | 亚洲第一成年网| 久久综合久久鬼色中文字| 91网站最新地址| 奇米影视一区二区三区| 国产精品看片你懂得| 欧美日韩国产一级片| 国产传媒久久文化传媒| 亚洲午夜电影网| 国产亚洲视频系列| 欧美日韩在线播放| 国产宾馆实践打屁股91| 日日夜夜精品视频免费| 国产精品黄色在线观看| 日韩欧美一级精品久久| 色嗨嗨av一区二区三区| 欧美影视一区在线| 久久福利视频一区二区| 亚洲一二三四在线观看| 欧美精品一区二区精品网| 欧美综合视频在线观看| 国产91丝袜在线播放九色| 日韩国产精品久久| 亚洲精品高清在线| 国产精品系列在线| 精品剧情在线观看| 精品视频1区2区3区| 99国产精品久久久| 国产一区二区三区久久久| 日本一道高清亚洲日美韩| 亚洲美女免费视频| 中文字幕av在线一区二区三区| 日韩一级免费观看| 欧美日韩精品是欧美日韩精品| av动漫一区二区| 国产999精品久久| 黄色日韩三级电影| 日韩激情视频网站| 亚洲国产欧美日韩另类综合| 国产精品福利av| 欧美韩国日本综合| 国产亚洲制服色| 26uuu亚洲综合色欧美| 日韩一卡二卡三卡| 91精品国产品国语在线不卡| 在线亚洲一区二区| 99国产欧美另类久久久精品| 国产盗摄视频一区二区三区| 国产一区二区视频在线| 蜜臀av一区二区在线观看| 亚洲h在线观看| 亚洲成人免费电影| 亚洲国产综合91精品麻豆| 一区二区在线观看不卡| 成人免费一区二区三区视频|