If statement: a dictionary-based 'switch',,choice = 'ha
If statement: a dictionary-based 'switch',,choice = 'ha
choice = 'ham'print {'spam': 1.25, # a dictionary-based 'switch' 'ham': 1.99, # use has_key() or get() for default 'eggs': 0.99, 'bacon': 1.10}[choice]if choice == 'spam': print 1.25elif choice == 'ham': print 1.99elif choice == 'eggs': print 0.99elif choice == 'bacon': print 1.10else: print 'Bad choice'
- Iterating Over Lines with readlines,iteratingreadlines
- if Statements: if, elif and else,statementselif,x = in
- Loop through a list: for in,loopthrough,a = ['cat',
- Generate binary message catalog from textual translation
- Change dictionary entry,dictionaryentry,d2 = {'spam'
- Concantenate a string by '\',concanten
热门文章:
相关内容
- Iterating Over Lines with readlines,iteratingreadlines,f = open('fi
- if Statements: if, elif and else,statementselif,x = int(raw_
- Loop through a list: for in,loopthrough,a = ['cat',
- Generate binary message catalog from textual translation description,
- Change dictionary entry,dictionaryentry,d2 = {'spam'
- Concantenate a string by '\',concantenatestring,bar
- Write Unicode strings directly to flout,stringsflout,import codec
- Button font: underline italic,underlineitalic,from Tkinter
- Tuple is not changable,tuplechangable,T = (1, 2, 3
- A sentence is split up into a list of words,sentencesplit,sentence
评论关闭