python の変更点   

  • 追加された行はこの色です。
  • 削除された行はこの色です。
  • python へ行く。

#author("2019-09-04T05:25:31+00:00","default:pentacle","pentacle")
* install [#n29fde36]

*** centos [#ua43591d]
 yum install https://centos7.iuscommunity.org/ius-release.rpm
 yum install python36

*** windows (cygwin) [#u32816cd]
 cd /usr/bin/
 wget https://raw.github.com/kou1okada/apt-cyg/master/apt-cyg
 chmod +x apt-cyg
 apt-cyg install python3

* stdin [#n478f6d4]
 #!/usr/bin/python36
 import fileinput,re
 for l in fileinput.input():
   line = l.rstrip()
   m = re.search('([0-9]+):' , line);
   if m :
       print( m.group(1) );

* file open [#h9fff95e]
 f = open(file,'r')
 for l in f.readlines():
   line = l.rstrip()		
   print(line) 
 f.close()

* unixtime [#g10f6faf]

 from datetime import datetime
 d = datetime.strptime("2019-04-10 10:48:56",'%Y-%m-%d %H:%M:%S') # str -> date型
 unixtime = d.timestamp()        # double型 (unixtime) 
 datetime.fromtimestamp( unixtime ) # date型 
 str = datetime.strftime('%Y%m%d%H%M%S')

* system [#k42cf6bf]
 proc = subprocess.run('ls *.jpg', shell=True,stdout = subprocess.PIPE, stderr = subprocess.PIPE)
 res = proc.stdout.decode("utf8").split()
 for line in res:
    print(line)

* sprintf [#o4dbd4f3]
 print ("%04d-%02d-%02d" % (year , month, date))

* if [#lfd3a116]
 if a==b and b==c:
     pass
 else:
   print "hoge\n";


* snipet [#x38a7918]
 #!/usr/bin/python3
 import subprocess,re,fileinput,pprint
 from datetime import datetime
 
 def system(cmd):
	proc = subprocess.run(cmd, shell=True,stdout = subprocess.PIPE, stderr = subprocess.PIPE)
	res = proc.stdout.decode("utf8").split()
	return res
 # ---------------------------
 res = system("ls *.jpg")
 for line in res:
    print(line)
 
 for l in fileinput.input():
  line = l.rstrip()
  if re.findall(【regex】,line):
      print(line)