Advertisement
Guest User

Untitled

a guest
Feb 25th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. # slop.py
  5. #
  6. # 20170225 ono
  7. #
  8. import re
  9.  
  10. C_VALUE = 10
  11.  
  12. j = 0
  13. for i in range(5):
  14. print('value:' + '\t' + str(C_VALUE + i))
  15.  
  16. j += 5
  17. if j % 10 == 0:
  18. print('\t' + 'fives.')
  19. else:
  20. print('\t' + 'tens.')
  21.  
  22. vals = ['a', 'b', 'c']
  23.  
  24. if 'a' in vals:
  25. print '\'a\' is in vals.'
  26.  
  27. print ('the 2nd is: ' + vals[2 - 1])
  28.  
  29. print ('len of vals: ' + str(len(vals)))
  30. for val in vals:
  31. print val
  32.  
  33. fin = open('input.txt', 'r')
  34. fout = open('output.txt', 'w')
  35. for line in fin:
  36. print ('input.txt: ' + line.rstrip())
  37. fout.write('output.txt: ' + line.rstrip() + '\n')
  38. fin.close()
  39. fout.flush()
  40. fout.close()
  41.  
  42. fin = open('output.txt', 'r')
  43. for line in fin:
  44. print ('output.txt: ' + line.rstrip())
  45. fin.close
  46.  
  47. reGroup = re.compile(r'^([^:]*):([^[]*)\[([^]]*)\]')
  48. mo = reGroup.search('time:1642[info]')
  49. if mo:
  50. print mo.group(1) + '\t' + mo.group(2) + '\t' + mo.group(3)
  51.  
  52. reNumber = re.compile(r'[0-9]{2,}')
  53. for m in reNumber.findall('abcd123ef5gh6789ijkl0'):
  54. print m
  55.  
  56. dic = {}
  57. k = 'mykey'
  58. v = 888
  59. dic[k] = dic.get(k, 0) + v
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement