Session3 : Today's Learning

The sequence of methods in the same command line

# If there are a sequence of methods in the same command line, methods are executed from left to right.

string1 = "2022-03-21"

string1.replace('-','/').replace('2022/0','')

print(string1)

# "3/21"

Another effective way to input arguments at Terminal

# Instead of using 'input()', you can use 'readline()' method from 'stdin' module of 'sys' package. 

import sys

n = sys.stdin.readline().rstrip()

# you'd better use '.rstrip()' to remove the following '\n'.

좋은 웹페이지 즐겨찾기