프로세서(Processor)는 컴퓨터 하드웨어 구성요소 중 운영체제와 가장 밀접한 하드웨어 입니다. 컴퓨터 운영을 위해서 기본적인 명령어들을 처리하고 반응하는 논리 회로 입니다. 컴퓨터의 두뇌라고 할 수 있는데 모든 컴퓨터의 작동과정이 프로세서의 제어를 받기 때문입니다. 프로세서는 레지스터, 산술 논리 연산장치, 제어장치 등으로 구성되는데요 우리가 흔히 사용하는 PC 에서는 주기억장치를 제외한 레지스터, 산술 논리 연산장치, 제어장치를 하나의 칩으로 구성한 마이크로프로세서를 보통 이용합니다.

 

참고

운영체제 그림으로 배우는 원리와 구조 개정판

위키백과 https://ko.wikipedia.org/wiki/%EC%A4%91%EC%95%99_%EC%B2%98%EB%A6%AC_%EC%9E%A5%EC%B9%98

Posted by ElvinKim
,

[python] naming rule

Python 2015. 7. 23. 09:55

Naming

module_name, package_name, ClassName, method_name, ExceptionName, function_name, GLOBAL_CONSTANT_NAME, global_var_name, instance_var_name, function_parameter_name, local_var_name.

Names to Avoid

single character names except for counters or iterators

dashes (-) in any package/module name

__double_leading_and_trailing_underscore__ names (reserved by Python)

Naming Convention

"Internal" means internal to a module or protected or private within a class.

Prepending a single underscore (_) has some support for protecting module variables and functions (not included with import * from). Prepending a double underscore (__) to an instance variable or method effectively serves to make the variable or method private to its class (using name mangling).

Place related classes and top-level functions together in a module. Unlike Java, there is no need to limit yourself to one class per module.

Use CapWords for class names, but lower_with_under.py for module names. Although there are many existing modules named CapWords.py, this is now discouraged because it's confusing when the module happens to be named after a class. ("wait -- did I write import StringIO or from StringIO import StringIO?")

Guidelines derived from Guido's Recommendations

Type Public Internal

Packages lower_with_under

Modules lower_with_under _lower_with_under

Classes CapWords _CapWords

Exceptions CapWords

Functions lower_with_under() _lower_with_under()

Global/Class Constants CAPS_WITH_UNDER _CAPS_WITH_UNDER

Global/Class Variables lower_with_under _lower_with_under

Instance Variables lower_with_under _lower_with_under (protected) or __lower_with_under (private)

Method Names lower_with_under() _lower_with_under() (protected) or __lower_with_under() (private)

Function/Method Parameters lower_with_under

Local Variables lower_with_under

Main

Posted by ElvinKim
,

프로그램 작성 중 다음과 같은 '[Decode error - output not utf-8]' 인코딩 관련 에러가 발생했을 때 해결책을 정리하려 합니다.


1. Sublime Text 2 에서 Preferences => Browse Packages.... 를 클릭합니다.


2. python 폴더에 들어 갑니다.

3. Python.sublime-build 파일을 엽니다.

4. cmd 창에서 chcp 명령어를 보고 활성 코드 페이지를 확인합니다.

5. 만약 활성 코드 페이지가 949 라면 Python.sublime-build 파일에 다음을 넣고 저장합니다.


Posted by ElvinKim
,

npm install 을 실행했을 때 nodejs/windows Error: ENOENT, stat 'C:\Users\Administrator\AppData\Roaming\npm' 에러가 나올 때가 있다. 이때는 'C:\Users\Administrator\AppData\Roaming\" 경로 까지 가서 npm 폴더를 만들어 주면 된다. 윈도우 상에서는 AppData 폴더가 보이지 않으므로 cmd 창에서 경로를 따라 들어가 만들어 주면 된다.

Posted by ElvinKim
,

Putty 나 다른 원격 접속 프로그램으로 리눅스에 접근한 뒤 종료하면 실행 중이던 프로그램이 종료 된다

이럴 때 putty 를 종료해도 프로그램은 종료 되지 않고 계속 수행하고 싶다면 nohup 명령어를 사용하면 된다.

사용 예를 보면

-bash-3.2# nohup python test.py & 

다음과 같이 사용하면 된다.


Posted by ElvinKim
,

제목이 너무나 기네요. MySQLdb 모듈을 사용하여 INSERT 혹은 UPDATE를 실행한 뒤 에러가 없이 코드가 

실행 되었지만 DB 상에는 INSERT UPDATE 가 되지 않은 상태라면 DB Engine innoDB 인지 확인해 

봅니다. 만약 innoDB 가 맞다면 아래의 코드를 삽입합니다.


db 	= MySQLdb.connect(host="",user="",passwd="",db="")
db.autocommit(True)


autocommit(True)를 삽입하면 해결 될 것 입니다.

Posted by ElvinKim
,

python 에서 텍스트를 처리할 때 특수문자를 제거해야 할 때가 있습니다. 이럴 때 정규표현식 으로 처리할 수도 

있지만 다음과 같이 처리할 수도 있습니다.


sampleString = "1234567890abcdefgABCDEFG!@#$%^&*()_{}[]<>"
resultString = ""

for c in sampleString:
	if c.isalnum():
		resultString +=c

print resultString

결과는

1234567890abcdefgABCDEFG

[Finished in 0.2s]

Posted by ElvinKim
,

Python 에서 dictionary를 사용하다 보면 key 값의 존재 유무를 알아야 할 때가 있습니다.

예를 들어 [“a”, “b”, “c”, “c”, “a”, “a”, “b”, “b”, “a”, “a”, “a”, “a”] 같은 리스트에서 각각의 요소 개수를 

dictionary 로 관리 하고 싶을 때 각각의 카운트를 세야 하기 때문입니다. 물론 collections 같은 모듈을 사용할 

수도 있지만 dictionary 에 넣어야 하는 상황이라고 가정해 봅니다. 그럴 때 사용하는 것이 has_key 함수 입니

.


sampleDict ={"a":1 , "b":2}

print sampleDict.has_key("a")
print sampleDict.has_key("b")
print sampleDict.has_key("c")

결과는

True

True

False

[Finished in 0.2s]


그래서 위에 상황을 구현해 본다면

sampleList = ["a", "b", "c", "c", "a", "a", "b", "b", "a", "a", "a", "a"]
sampleDict = {}

for ele in sampleList:
	if sampleDict.has_key(ele):
		sampleDict[ele] += 1
	else :
		sampleDict[ele] = 1

print sampleDict


결과는

{'a': 7, 'c': 2, 'b': 3}

[Finished in 0.2s]

Posted by ElvinKim
,
SELECT name FROM your_table_name WHERE BINARY(name) LIKE "%your search word%"

'MySQL' 카테고리의 다른 글

[MySQL]외부 접속 허용  (0) 2014.10.21
Posted by ElvinKim
,
sampleList= [1,2,3,4,5,6,1,2,3,4,5,6]

print list(set(sampleList))


결과 :

[1, 2, 3, 4, 5, 6]

[Finished in 0.2s]

Posted by ElvinKim
,