Using the and-or Trick Safely,and-ortrick,a = '' b = '
Using the and-or Trick Safely,and-ortrick,a = '' b = '
a = '' b = 'second' print (1 and [a] or [b])[0]# Since [a] is a nonempty list, it is never false. Even if a is 0 or '', # or some other false value, the list [a] is true because it has one element.
- print rounds off digits,roundsdigits,a = 3
- Create Python codecs from Unicode mapping files,codecs
- Mixed-type conversions,mixed-type,a = 3
- Key action: Return key,keyactionreturn,from Tkinter
- String escape sequences Demo,escapesequences,print '\a
- Unit test for apihelper.py,unitapihelper.py,'''Unit te
热门文章:
相关内容
- print rounds off digits,roundsdigits,a = 3
- Create Python codecs from Unicode mapping files,codecsmapping,'''PY
- Mixed-type conversions,mixed-type,a = 3
- Key action: Return key,keyactionreturn,from Tkinter
- String escape sequences Demo,escapesequences,print '\a'pr
- Unit test for apihelper.py,unitapihelper.py,'''Unit test
- keyword arguments,arguments,def birthday
- Import a specific member from a module,importspecific,#//File: mod
- Reading and Writing Files: open() a file,readingwriting,#open() ret
- Displaying location, type and value for an int,displayinglocation,i
评论关闭