http://www.joinc.co.kr/modules/moniwiki/wiki.php/Site/C/Documents/COptimization


몇몇개는 지금은 해당되지 않는 것도 있지만, 

꽤나 설득력 있는 것들도 많은 것 같다.


기왕 시뮬레이터를 손대기로 한 것이니, 조금씩 더 개선해보자.

'C and C++' 카테고리의 다른 글

OpenMP in Macbook  (0) 2016.03.10
OpenMP  (0) 2016.03.09
걸음마  (0) 2015.12.08
Fixed point with C++  (0) 2015.12.08
C++ , 객체지향  (0) 2015.12.08

1. library 불러오기

from datetime import datetime


2. 현재시간

from datetime import datetime


now = datetime.now()

print now


3. 년/월/일

from datetime import datetime


now = datetime.now()

print now

print now.year

print now.month

print now.day


from datetime import datetime

now = datetime.now()


print '%s/%s/%s' % (now.month, now.day, now.year)


4. 시:분:초

from datetime import datetime

now = datetime.now()


print '%s:%s:%s' % (now.hour, now.minute, now.second)

3.4 는 print 문법이 완전 다르구나 print ('{}:{}:{}' .format(now.hour, now.minute, now.second))


5. datetime 관련 정리

from datetime import datetime

now = datetime.now()


print '%s/%s/%s %s:%s:%s' % (now.month, now.day, now.year, now.hour, now.minute, now.second)


'Python' 카테고리의 다른 글

functions  (0) 2016.02.08
Pig Latin  (0) 2016.02.08
Conditional and control flow  (0) 2016.02.05
string  (0) 2016.02.02
python 걸음마 시작  (0) 2016.02.02

1.

brian = "Hello life!"


2. 문자열 변수 할당 및 출력

# Assign your variables below, each on its own line!


caesar = "Graham"

praline = "John"

viking = "Teresa"


# Put your variables above this line


print caesar

print praline

print viking


3. 특문은 역슬래시

'This isn\'t flying, this is falling with style!'


4. index starts from 0

string = "MONTY"

fifth_letter = string[4]


print fifth_letter


5. 문자열 길이 함수

parrot = "Norwegian Blue"

print len(parrot)


6. 문자열 함수 사용법 - 뭔가 문자열 객체에다가 점 찍어서 관련 함수를 사용하는 듯

parrot = "Norwegian Blue"

print parrot.lower()

print parrot.upper()


7.  문자열로 변환하는 함수

pi = 3.14

print str(pi)


8. dot notation 사용 주의

ministry = "The Ministry of Silly Walks"


print len(ministry)

print ministry.upper()


9. print string

print "Monty Python"


10. 문자열 변수 출력하기

the_machine_goes = "Ping!"

print the_machine_goes


11. string concatenation

print "Spam " + "and " + "eggs"

print "The value of pi is around " + str(3.14)


12. 문자열 포맷 지정자: %s 로 큰 따옴표 내에서 문자열 대치할 수 있음 

    대치되는 문자열 변수들은 큰 따옴표 뒤에 %(변수 나열)  식으로 해서 넣음

    "문자열 %s" %(string)

name = raw_input("What is your name?")  #문자열 입력 받아오는 함수 with comment

quest = raw_input("What is your quest?")

color = raw_input("What is your favorite color?")


print "Ah, so your name is %s, your quest is %s, " "and your favorite color is %s." % (name, quest, color)


13.

my_string = "Keol Cho"

print len(my_string)

print my_string.upper()




'Python' 카테고리의 다른 글

functions  (0) 2016.02.08
Pig Latin  (0) 2016.02.08
Conditional and control flow  (0) 2016.02.05
datetime library  (0) 2016.02.04
python 걸음마 시작  (0) 2016.02.02

+ Recent posts