input('아이디를 입력하세요 : ')
아이디를 입력하세요 :
id = input('아이디를 입력하세요 : ')
print(id)
아이디를 입력하세요 : rimi0108
rimi0108
id = input('아이디를 입력하세요 : ')
if id == 'rimi0108' :
print(id + '님 환영합니다.')
아이디를 입력하세요 : rimi0108
rimi0108님 환영합니다.
id = input('아이디를 입력하세요 : ')
if id == 'rimi0108' :
print(id + '님 환영합니다')
else :
print('아이디가 존재하지 않습니다.')
아이디를 입력하세요 : hyerim1234
아이디가 존재하지 않습니다.
user_id = 'hye1111'
user_passwd = 'rim2222'
id = input('아이디를 입력하세요 : ')
passwd = input('비밀번호를 입력하세요 : ')
if id == user_id and passwd == user_passwd:
print(id + '님 환영합니다.')
elif id != user_id and passwd == user_passwd:
print('아이디가 일치하지 않습니다.')
elif id == user_id and passwd != user_passwd:
print('비밀번호가 일치하지 않습니다.')
elif id != user_id and passwd != user_passwd:
print('아이디와 비밀번호가 일치하지 않습니다.')
True and True
True and False
False and False
True
False
False
True or True
False or True
False of False
True
True
False
not True
not False
False
True
a = [1, 2, 3, 4, 5, 6]
print(a)
print(a[0])
print(len(a))
a[1] = 4
print (a)
del a[1]
print(a)
a.append('a')
print(a)
[1, 2, 3, 4, 5, 6]
1
6
[1, 4, 3, 4, 5, 6]
[1, 3, 4, 5, 6]
시퀀스 자료형이란 각 요소들이 마치 한 영화의 이어지는 에피소드처럼 연속적으로 이루어진 자료형이다.
a = [1, 2, 3, 4, 5] # 리스트(list)
b = (1, 2, 3, 4, 5) # 튜플(tuple)
c = range(10) # 레인지(range)
d = 'Python' # 문자열(string)
print(len(a))
5
print(b[2])
3
print(b[1:4])
print(b[2:5:2])
(2, 3, 4)
(3, 5)
a = [1, 2, 3, 4, 5]
b = [10, 20, 30, 40, 50]
print(a + b)
[1, 2, 3, 4, 5, 10, 20, 30, 40, 50]
*
연산자를 사용해 시퀀스 객체를 원하는 숫자만큼 반복할 수 있습니다.a = [1, 2, 3, 4, 5]
print(a * 2)
[1, 2, 3, 4, 5, 1, 2, 3, 4, 5]
person = {'name':'choihyerim' 'age': 23}
person['name']
person[age]
choihyerim
23
for value in ['a', 'b', 'c', 'd']:
print(value)
a
b
c
d
for i in range(10):
print(i)
0
1
2
3
4
5
6
7
8
9
form = cgi.FieldStorage()
if 'id' in form:
pageId = form["id"].value
else:
pageId = 'Welcome'
if 'id' in form:
pageId = form["id"].value
open('data/'+pageId, 'r').read()
else:
pageId = 'Welcome'
description = 'Hello web'
import cgi, os
files = os.listdir('data')
print(files)
listStr = ''
for item in files:
listStr = listStr + item
print(listStr)
['JavaScript', 'HTML', 'CSS']JavaScriptHTMLCSS
files = os.listdir('data')
listStr = ''
for item in files:
listStr = listStr + '<li><a href="index.py?id={name}">{name}</a></li>'.format(name=item)
print(listStr)
JavaScript HTML CSS
<li><a></a></li>
로 출력되게 만든다.<참고>