Python学习(一)HelloWorld程序
1、windows7上安装Python环境2、PythonGUI(IDLE)
3、写第一个Python代码
# FileName=HelloWorld.py
print 'HelloWorld'
4、run
=============================
word="abcdefg"
a=word
print "a is: "+a
b=word
print "b is: "+b # index 1 and 2 elements of word.
c=word[:2]
print "c is: "+c # index 0 and 1 elements of word.
d=word
print "d is: "+d # All elements of word.
e=word[:2]+word
print "e is: "+e # All elements of word.
f=word[-1]
print "f is: "+f # The last elements of word.
g=word[-4:-2]
print "g is: "+g # index 3 and 4 elements of word.
h=word[-2:]
print "h is: "+h # The last two elements.
i=word[:-2]
print "i is: "+i # Everything except the last two characters
l=len(word)
print "Length of word is: "+ str(l)
页:
[1]