맥북에서 파일에서 읽고 한줄 씩 출력하기
==================================================
Sample 1 – Read – Display
==================================================
file_name = ‘/readtest1.txt’
f = open(file_name, ‘r’)
lines = f.readlines()
f.close()
line_num = 0
for line in lines:
line_No = line_num + 1
print(“{0}: {1}”.format(line_No, line),end=”)
==================================================
Sample 2 – Write – Display
==================================================
file_name = ‘/write_test.txt’
f = open(file_name, ‘w’)
f.write(“Python;\n”)
f.write(“c++;\n”)
f.write(“flutter;\n”)
f.close()
print(“created: “, file_name)
==================================================
Sample 3 – split str.split([sep]), str.strip([chars])
==================================================
Sample 4 – Jupyter Web Execution
jupyter notebook
==================================================
Sample 5 – str.join(seq)
==================================================
Sample 6 – str.find(search_str, [,start, end])
==================================================
Sample 7 – str.count(search_str, [,start, end]) ,,, startwith, endswith
==================================================
Sample 8 – str.replace(old_str, new_str[, count])
==================================================
Sample 9 – str.lower() str.upper()
==================================================