#!/usr/bin/python
#coding=utf8
print "What's your name?"????????????????#雙引號包裹單引號
print 'What\'s your name?'???????????????#使用轉(zhuǎn)義符
a=1998
b="free"
print b + str(a)?????????????????????????#str()把int轉(zhuǎn)換為string
print b + repr(a)????????????????????????#repr() 函數(shù)炫加,同\反引號
name = raw_input("What is your name?")
age = raw_input("How old are you?")
type(age)????????????????????????????????#
print "Your name is:",name
print "You are"+age +" years old."???????# print() 默認(rèn)是以\n 結(jié)尾的
print r"c:\news\python"??????????????????# 在字符串開頭加 t ,原始字符串輸出
lang="study python"
b=lang[1:]???????????????????????????????#從 1 號到最末尾的字符
c=lang[:]????????????????????????????????#得到所有字符
d=lang[:10]??????????????????????????????#從第一個(gè)到 10 號之前的字符
#如果分號的前面或者后面的序號不寫驻呐,就表示是到第一個(gè)(前面的不寫)或最末(后面的不寫)
str1="abc"
str2="123"
print str1 + "-->" +str2??????????????????# + 連接字符串
print "a" in str1?????????????????????????# in 包含返回true,否則false
print max(str1)???????????????????????????#max
print cmp(str1,str2)???????????????
print ord('a')????????????????????????????#ord??得到字符對應(yīng)的數(shù)
print str1*3??????????????????????????????# * 重復(fù)
print len(str1)???????????????????????????# 字符串有多少字符
print "I like %s" % "python"??????????????#%s
print "I like {}".format("python")????????#string.format()
a="I love Python"
print a.split(" ")????????????????????????# split 返回list
b="hello "
print "strip:",b.strip()??????????????????# 去空格
a = "This is a Book"
print "a.istitle() ",a.istitle()??????????#判斷每個(gè)單詞的第一個(gè)字母是否為大寫
b='www.itdiffer.com'
c=b.split(".")
print c
print "join:",".".join(c)?????????????????# join 拼接list
結(jié)果