Handling I/O Errors,handlingerrors,# shows how
Handling I/O Errors,handlingerrors,# shows how
# shows how to safely open and read from a file and gracefully handle errors.try: fsock = open(filename, 'rb', 0) try: fsock.seek(-128, 2) tagdata = fsock.read(128) finally: fsock.close() except IOError: pass
- Reads a single line from the file,readssingle,f=open('
- Check a user name and PIN code,checkpin,database = [
- Using the break statement in a for structure.,statemen
- Dictionary key membership test alternative,,d2 = {'spa
- Change .py files to use 4-space indents.,.pyindents,''
- Join a list,joinlist,li = ['a', '
热门文章:
相关内容
- Reads a single line from the file,readssingle,f=open('/tmp
- Check a user name and PIN code,checkpin,database = [
- Using the break statement in a for structure.,statementstructure,fo
- Dictionary key membership test alternative,,d2 = {'spam'
- Change .py files to use 4-space indents.,.pyindents,'''PYTHON SO
- Join a list,joinlist,li = ['a', '
- String formatting: Float, Default Float and Default exponential,,fl
- Sampling without replacement,,import rando
- Functional Programming Tools: reduce 2,functionalreduce,# If there'
- Replace tabs with spaces in argument files,tabsargument,'''PYTHON S
评论关闭