반응형
반응형

python 문자열 아스키코드 알아내기


# 문자열에서 아스키 코드값 추출

print(ord('a')) => 97


# 아스키 코드에서 문자열로 변환 : https://namu.wiki/w/%EC%95%84%EC%8A%A4%ED%82%A4%20%EC%BD%94%EB%93%9C

print(chr(65)) => A


# 슬라이싱을 이용하여서 문자열의 아스키 값 추출하기

chr(int(Str[시작:끝])))

- 이때 시작값은 0부터 시작이다.

반응형
반응형

정규식 문법

사용 문자

사용법

의미

비고

.

a.b

\n(줄 바꿈)를 제외한 모든 문자와 매치됨을 의미한다.

즉, a와 b 문자 사이에 모든 문자가 허용된다.

ex) aab, acb, afb, a3b ....


^

^app

문자열의 시작을 나타낸다.

ex) ^app apple.... , appads ..

즉, app~로 시작하는 문자열이 모두 매치된다.


$

ple$

문자열의 종료를 나타낸다.

ex) abcple, aee3ple, oefple ....


[]

apple[a-z]

집합을 의미한다.

ex) [abcd]의 경우 a 또는 b 또는 c또는 d를 의미한다.

ex) [^5]일 경우 5를 제외한 모든 문자를 의미한다.

ex) [a-c]일 경우, a~c 문자를 의미한다.

apple[a-z]는 applee, applec... 와 매치되고 

apple4, appleE와 같은 문자일 경우, 매치되지 않는다.


|

a|b

OR 연산을 의미한다. 

ex) a|b는 a 또는 b문자열을 의미한다.


()

(a|b)

괄호 안의 정규식을 group으로 만든다.

직접 괄호를 통하여 매칭하기 위해서 \(, \[로도 나타낸다.


*

ca*t

0회 이상 반복되는 것을 의미한다. 

ex) ca*t는 ct, cat, caat, caaaaat) 등과 매치된다.


+

a+

1회 이상 반복되는 것을 말한다.

ex) cat, caaat 등


?

ca?t

0회 또는 1회 이상 반복되는 것을 의미한다.

ex) ca?t는 cat, ca와 매치된다.


{m}

 ca{2}

{m}회 반복하는 것을 말한다. 

ex) ca{2}는 caa와 매치된다. 

 

{m, n}

 ca{m,n}

m 회부터 n회까지 반복됨을 말한다.

ex) ca{2,4}p는 caap, caap, cbbbp와 매치된다.

 

{m,}

 

 

 


정규식 예제

import re


print (bool(re.match( '[a-c]{3}', 'aaa')))

→ True


반응형
반응형

pip 명령어가 안먹히거나, pycharm에서 해당 에러메시지로 설치가 안되는 경우 (SSL: CERTIFICATE_VERIFY_FAILED)




Collecting pip==9.0.1

  Could not fetch URL https://pypi.python.org/simple/pip/: There was a problem confirming the ssl certificate: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645) - skipping


  Could not find a version that satisfies the requirement pip==9.0.1 (from versions: )

No matching distribution found for pip==9.0.1


1. 수정할 파일 경로
C:\Users\사용자 이름\AppData\Local\Programs\Python\Python35\Lib\site-packages\pip\_vendor\requests\sessions.py

2. sessions.py 수정

   .............     

   #: SSL Verification default. False #★

        self.verify = False

   .............

sessions.py에 있는 모든 verify=True로 되어있는 것을 False로 모두 바꾼다!!

3. 다시 pycharm을 통해서 tensorflow 재설치

4. 설치완료 후, Tensorlfow 예제 실행

import tensorflow as tf


hello = tf.constant('Hello, TensorFlow!')

sess = tf.Session()

print(sess.run(hello))

5. 결과

C:\Users\Aileen\AppData\Local\Programs\Python\Python35\python.exe E:/skcomms/PycharmProject/testProject/HelloTensor.py

b'Hello, TensorFlow!'


E c:\tf_jenkins\home\workspace\release-win\device\cpu\os\windows\tensorflow\core\framework\op_kernel.cc:943] OpKernel ('op: "BestSplits" device_type: "CPU"') for unknown op: BestSplits

E c:\tf_jenkins\home\workspace\release-win\device\cpu\os\windows\tensorflow\core\framework\op_kernel.cc:943] OpKernel ('op: "CountExtremelyRandomStats" device_type: "CPU"') for unknown op: CountExtremelyRandomStats

E c:\tf_jenkins\home\workspace\release-win\device\cpu\os\windows\tensorflow\core\framework\op_kernel.cc:943] OpKernel ('op: "FinishedNodes" device_type: "CPU"') for unknown op: FinishedNodes

E c:\tf_jenkins\home\workspace\release-win\device\cpu\os\windows\tensorflow\core\framework\op_kernel.cc:943] OpKernel ('op: "GrowTree" device_type: "CPU"') for unknown op: GrowTree

E c:\tf_jenkins\home\workspace\release-win\device\cpu\os\windows\tensorflow\core\framework\op_kernel.cc:943] OpKernel ('op: "ReinterpretStringToFloat" device_type: "CPU"') for unknown op: ReinterpretStringToFloat

E c:\tf_jenkins\home\workspace\release-win\device\cpu\os\windows\tensorflow\core\framework\op_kernel.cc:943] OpKernel ('op: "SampleInputs" device_type: "CPU"') for unknown op: SampleInputs

E c:\tf_jenkins\home\workspace\release-win\device\cpu\os\windows\tensorflow\core\framework\op_kernel.cc:943] OpKernel ('op: "ScatterAddNdim" device_type: "CPU"') for unknown op: ScatterAddNdim

E c:\tf_jenkins\home\workspace\release-win\device\cpu\os\windows\tensorflow\core\framework\op_kernel.cc:943] OpKernel ('op: "TopNInsert" device_type: "CPU"') for unknown op: TopNInsert

E c:\tf_jenkins\home\workspace\release-win\device\cpu\os\windows\tensorflow\core\framework\op_kernel.cc:943] OpKernel ('op: "TopNRemove" device_type: "CPU"') for unknown op: TopNRemove

E c:\tf_jenkins\home\workspace\release-win\device\cpu\os\windows\tensorflow\core\framework\op_kernel.cc:943] OpKernel ('op: "TreePredictions" device_type: "CPU"') for unknown op: TreePredictions

E c:\tf_jenkins\home\workspace\release-win\device\cpu\os\windows\tensorflow\core\framework\op_kernel.cc:943] OpKernel ('op: "UpdateFertileSlots" device_type: "CPU"') for unknown op: UpdateFertileSlots


Process finished with exit code 0



나머지 메시지들은 에러가 아니라 정상이고, windows 버전이 아직 안정적이지 않아서 뜨는 오류!


젠장..ㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅜㅠㅠㅠ을마나 삽질한거야 

반응형
반응형
  1. [WIKI 문서https://wikidocs.net/book/110
  2. [코드아카데미] https://www.codecademy.com/ko/courses/python-advanced-ko/0/1?curriculum_id=53b5e0d8fed2a81590000003


반응형

+ Recent posts