python语法(2)
#coding=utf-8 #%r,打印的字符串中有"",也会自动打印 #format函数格式化字符串 #首先定义formatter formatter = "%r %r %r %r" print (formatter % ('1','2','3','4')) print (formatter % ("one","two","three","four")) print (formatter % ( "I had this thing.", "That you could type up right.", "But it didn't sing.", "So I said goodnight." )) #\n是换行 #3个双引号包含的内容可以是多行存在的 print (""" there is something going on here with the three double-quotes we'll be able to type as much as we like even 4 lines if we want,or 4,or 6s """) #转义字符的使用 wang_cat="\tI'm tabbed in"#tab键的作用,输出八个空格 li_cat="I'm split\non a line"#\n换行符 chen_cat="I'm \\ a \\ cat" #\\是\ huang_cat=""" I'll do a list: \t* cat food \t* fishies \t* catnip\n\t *Grass """ print (wang_cat) print (li_cat) print (chen_cat) print (huang_cat) while True: for i in ["/","-","|","\\","|"]: print ("%s"%i)