#This support both python2 and python3
s=""
h="00233a990c21"
':'.join(h[i:i+2] for i in range(0,12,2))
print ('mac:'+h)
print ('mac format:'+':'.join(h[i:i+2] for i in range(0,12,2)))
```
string = "2018/01/02" " " "CCCC"
print string
#'2018/01/02 CCCC'
```
string.rstrip().split(' ')
#['2018/01/02', 'CCCC']
print string
#2018/01/02 CCCC
```
```
>>> string = "2018/01/02" " " "CCCC"
>>> element0=string.split()[0]
>>> element1=string.split()[1]
print (element0)
#2018/01/02
print element1
#CCCC
```
```
date_convert =(datetime.strftime(datetime.strptime(element0, '%Y/%m/%d'), '%Y%m%d'))
print date_convert
#20180102
```
```
new = date_convert +" " +element1
print new
#'20180102 CCCC'
```
```>>> a = "this is a string" >>> a = a.split(" ") # a is converted to a list of strings. >>> print a['this', 'is', 'a', 'string'] ```
```
>>> a = "-".join(a)
>>> print a
this-is-a-string
```
2010/02/15 aaaa
2010/04/15 aaaa
2010/03/15 aaaa
import datetime as dt
with open('holiday.txt') as f, open('new.txt', 'w') as f_out:
for line in f:
line = line.strip()
line =line.replace('/', '')
f_out.write('{}\n'.format(line))
2010/02/15
import datetime as dt
from datetime import datetime
with open('holiday.txt') as f, open('new.txt', 'w') as f_out:
for line in f:
line = line.strip()
#line =line.replace('/', '')
#f_out.write('{}\n'.format(line))
f_out.write(datetime.strftime(datetime.strptime(line, '%Y/%m/%d'), '%Y%m%d'))
output:2010/02/15 aaaa
2010/04/15 aaaa
2010/03/15 aaaa
import datetime as dt
from datetime import datetime
with open('holiday.txt') as f, open('new.txt', 'w') as f_out:
for line in f:
line = line.strip()
#line =line.replace('/', '')
#f_out.write('{}\n'.format(line))
#f_out.write(datetime.strftime(datetime.strptime(line, '%Y/%m/%d'), '%Y%m%d'))
line.rstrip().split(' ')
line_1 = line.split()[0]
line_2 = line.split()[1]
newline =(datetime.strftime(datetime.strptime(line_1, '%Y/%m/%d'), '%Y%m%d'))
#result = line_1 +" " +line_2
#f_out.write(result)
f_out.write(line_1 +" " +line_2+ '\n')
output:2010/02/15 aaaa
2010/04/15 aaaa
2010/03/15 aaaa
from datetime import datetime
with open('holiday.txt') as f, open('new.txt', 'w') as f_out:
for line in f:
line_1, line_2 = line.rstrip().split(' ')
new_line_1 =(datetime.strftime(datetime.strptime(line_1, '%Y/%m/%d'), '%Y%m%d'))
f_out.write('{} {}\n'.format(new_line_1, line_2))
output:pip install python-dateutil
Chaged format from XX/XX/XXX to XXXXXX using strftimfrom datetime import datetime
d = "2018/01/02"
print(datetime.strftime(datetime.strptime(d, '%Y/%m/%d'), '%Y%m%d'))
Output: from datetime import datetime
d = "2018/01/02"
print(datetime.strftime(datetime.strptime(d, '%Y/%m/%d'), '%Y%m%d
Output: ```
# -*- coding: utf-8 -*-
#
import os
#python2.X
a = raw_input("enter your name : ")
print "hell0"+a
os.system("pause")
#python3
#a = input("input:")
#print ("name"+ a)
```
#python 2
import sys
substring = raw_input("enter your string (Ex:20180810): ")
count =0
for line in open('POD_RDKB_10Year.txt'):
#if ("") in line:
if substring in line:
line = line.strip()
count +=1
print (line)
if count==0:
print ("string not found")
```
```
# python3
import sys
substring = input ("enter your string (Ex:20180810):: ")
count =0
for line in open('POD_RDKB_10Year.txt'):
#if ("") in line:
if substring in line:
line = line.strip()
count +=1
print (line)
if count==0:
print ("string not found")
```
Output
```
# -*- coding: utf-8 -*-
#
import sys
string = "Hello Agnosticdev, I love Tutorials"
substring = "Agnosticdev"
# Straight forward approach for Python 2.7 and Python 3.6
# Executes the conditional statement when the substring is found
if substring in string:
print ("Your substring was found!")
# Alternative Approach
# Use the find method in Python 2.7 or Python 3.6
if string.find(substring) is not -1:
print("Python found the substring!")
else:
print("Python did NOT find the substring!")
```
``` #support python2 and 3 def find(substr, infile, outfile): with open(infile) as a, open(outfile, 'w') as b: for line in a: if substr in line: b.write(line + '\n') print(line + '\n') # Example usage: find('20181109', 'POD_RDKB_10Year.txt', 'b.txt') ```
#git config --global user.name "YOUR NAME"
your email:#git config --global user.email "YOUR EMAIL ADDRESS"
#git config user.name
sample: git clone http//github.com/xxxxx/ooooo.
X: your username
0:your repository name
# under Linux utility, create a directory
mkdir GITHUB
# clone repository from server to local and download it. Test is repository
git clone http//github.com/chenchih/test
#go to test and create a file
touch 123456.txt
git commit -m "add file "
git push
#create new folder
mkdir testfolder
#also create folder in gitserver
add 'testfolder'
#commit it
git commit -am "Add testfolder"
git push
delete Folder#delete new folder
rm -rf testfolder
#also delete folder in gitserver
git rm -rf 'testfolder'
#commit it
git commit -m "Removed folder from repository"
git push
# go into folder directory
cd testfolder
git add *
git commit -m "with the message"
git push