'Programming/python(파이썬)'에 해당되는 글 95건

  1. 2020.01.11 python print 와 while 문
  2. 2020.01.11 오랫만에 한가로움?
  3. 2020.01.10 python split
  4. 2020.01.09 python 겅부
  5. 2020.01.09 python 관련 문서들
  6. 2020.01.02 python exception
  7. 2019.12.14 python 컴파일하기 및 디컴파일?
  8. 2019.12.13 python indent
  9. 2019.12.10 tensorflow, pytorch
  10. 2019.09.09 python pip 특정 버전설치 / 목록에서 설치

 

if guess == number:
    print('same')
elif guess < number:
    print('larger then')
else:
    print('lesser then')

 

node.js와는 다르게 문자열과 숫자를 마음대로 + 로 출력할 수가 없다.

그리고 while 문에 대해서도 특이하게 else가 붙어서 마지막 조건에서 벗어날때 무언가를 할 수 있다.

(무슨 용도로 이걸 만들었을까..)

cnt = 10;

while cnt > 0:

cnt = cnt - 1;

print('cnt:', cnt);

else:

print('cnt <= a', cnt);

 

[링크 : https://www.opentutorials.org/module/2980/17535]

'Programming > python(파이썬)' 카테고리의 다른 글

python 공부  (0) 2020.01.14
python 반복문 for in range()  (0) 2020.01.11
오랫만에 한가로움?  (0) 2020.01.11
python split  (0) 2020.01.10
python 겅부  (0) 2020.01.09
Posted by 구차니

머 애들이랑 놀아주는게 한가로울리가 없지만

그래도 마음 편하게 가족이랑 있으니 좋긴하네

'Programming > python(파이썬)' 카테고리의 다른 글

python 반복문 for in range()  (0) 2020.01.11
python print 와 while 문  (0) 2020.01.11
python split  (0) 2020.01.10
python 겅부  (0) 2020.01.09
python 관련 문서들  (0) 2020.01.09
Posted by 구차니

파싱을 위해 split 함수 혹은 tokenizer를 찾고 있는 중.

(regexp_split 같은 것도 있으려나?)

 

[링크 : https://wayhome25.github.io/python/2017/02/26/py-14-list/]

[링크 : https://wikidocs.net/13]

[링크 : https://www.w3schools.com/python/ref_string_split.asp]

[링크 : https://mainia.tistory.com/5624]

 

+

[링크 : https://stackoverflow.com/questions/13209288/python-split-string-based-on-regex]

'Programming > python(파이썬)' 카테고리의 다른 글

python print 와 while 문  (0) 2020.01.11
오랫만에 한가로움?  (0) 2020.01.11
python 겅부  (0) 2020.01.09
python 관련 문서들  (0) 2020.01.09
python exception  (0) 2020.01.02
Posted by 구차니

 

$ python3
Python 3.6.9 (default, Nov  7 2019, 10:44:02)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

5.4.5. 문자열 포맷팅
>>> age = 20
>>> name = 'Swaroop'
>>> print ("{0} was {1} years old".format(name, age))
Swaroop was 20 years old
>>> print ("{1} was {0} years old".format(name, age))
20 was Swaroop years old
>>> print ("{1:.3f} was {0} years old".format(name, age))
20.000 was Swaroop years old

5.4.7 순 문자열
>>> print(r"\a")
\a
>>> print("\a")

'Programming > python(파이썬)' 카테고리의 다른 글

오랫만에 한가로움?  (0) 2020.01.11
python split  (0) 2020.01.10
python 관련 문서들  (0) 2020.01.09
python exception  (0) 2020.01.02
python 컴파일하기 및 디컴파일?  (0) 2019.12.14
Posted by 구차니

이제 다시 한번 마스터 해봐야지..

node.js 해서 문법적으로 유사성을 찾으면 좀 쉬우려나?

 

[링크 : https://docs.python.org/3.8/download.html]

[링크 : http://byteofpython-korean.sourceforge.net/byte_of_python.pdf] 2.7 기준

'Programming > python(파이썬)' 카테고리의 다른 글

python split  (0) 2020.01.10
python 겅부  (0) 2020.01.09
python exception  (0) 2020.01.02
python 컴파일하기 및 디컴파일?  (0) 2019.12.14
python indent  (0) 2019.12.13
Posted by 구차니

C만 쓰다 보니 예외처리 부터 공부를 좀 해야겠다..

Cpp만 써봤어도 이해가 쉬울텐데...

 

[링크 : https://docs.python.org/ko/3/tutorial/errors.html]

[링크 : https://wikidocs.net/30]

'Programming > python(파이썬)' 카테고리의 다른 글

python 겅부  (0) 2020.01.09
python 관련 문서들  (0) 2020.01.09
python 컴파일하기 및 디컴파일?  (0) 2019.12.14
python indent  (0) 2019.12.13
tensorflow, pytorch  (0) 2019.12.10
Posted by 구차니

심심해서 잠도 안오겠다 -_-

python 가지고 놀다가 신기한 것 발견(?)

 

1. python2.x와 python3.x의 pyc 경로는 다르다.

2. python2.x와 python3.x의 pyc는 호환되지 않는다.

 

환경은 우분투 18.04 LTS. 설치된 버전정보는 다음과 같고

$ python --version
Python 2.7.15+

$ python3 --version
Python 3.6.9

 

python -m compileall . 과

python3 -m compileall . 의 결과는 아래와 같이

python(2.7.15)는 동일 경로상에 pyc로 생성되는데 반해

python3(3.6.9)는 __pycache__ 디렉토리 아래에 cpython 버전 정보를 기재하면서 pyc로 생성하게 된다.

.:
합계 20
drwxr-xr-x 3 minimonk minimonk 4096 12월 14 23:43 ./
drwxr-xr-x 5 minimonk minimonk 4096 12월 13 21:51 ../
drwxr-xr-x 2 minimonk minimonk 4096 12월 14 23:44 __pycache__/
-rw-r--r-- 1 minimonk minimonk   42 12월 14 23:43 test.py
-rw-r--r-- 1 minimonk minimonk  145 12월 14 23:43 test.pyc

./__pycache__:
합계 12
drwxr-xr-x 2 minimonk minimonk 4096 12월 14 23:44 ./
drwxr-xr-x 3 minimonk minimonk 4096 12월 14 23:43 ../
-rw-r--r-- 1 minimonk minimonk  140 12월 14 23:43 test.cpython-36.pyc

 

그리고 file 정보를 보면 pyc도 2.7대와 3.6대 byte-compiled로 나뉘게 되는데

$ file *
__pycache__: directory
test.py:     ASCII text
test.pyc:    python 2.7 byte-compiled

 

$ file __pycache__/*
__pycache__/test.cpython-36.pyc: python 3.6 byte-compiled

 

python2.7의 pyc를 python2.7과 python3.6으로 실행하면

python3.6 버전으로는 2.7의 pyc를 실행할 수 없다면서 에러를 발생시킨다.

$ python test.pyc
hello world
aa

$ python3 test.pyc
RuntimeError: Bad magic number in .pyc file

 

반대로  python3로 컴파일한 파일은

python2.7에서는 실행이 불가하고, python3.6으로는 실행이 가능하다.

$ python test.cpython-36.pyc 
RuntimeError: Bad magic number in .pyc file

$ python3 test.cpython-36.pyc 
hello world
aa

 

----

python -m compileall .

[링크 : https://sysops.tistory.com/39]

 

$ pip3 install uncompyle6
$ uncompyle6 -o . your_filename.pyc

[링크 : https://askubuntu.com/questions/153823/how-to-run-a-pyc-compiled-python-file]

[링크 : https://g0pher.tistory.com/364]

'Programming > python(파이썬)' 카테고리의 다른 글

python 관련 문서들  (0) 2020.01.09
python exception  (0) 2020.01.02
python indent  (0) 2019.12.13
tensorflow, pytorch  (0) 2019.12.10
python pip 특정 버전설치 / 목록에서 설치  (0) 2019.09.09
Posted by 구차니

웬지 이유없는 들여쓰기로 블록 구분하는건 안되는 느낌이다.

 

:로 끝나면 한블럭 들어가야 하고 이 경우는 if나 함수 처럼 어떠한 블럭이 강제되는 부분일 경우

들여쓰기를 강제하게 된다.

 

[링크 : https://riptutorial.com/ko/python/example/3952/블록-들여-쓰기]

[링크 :https://offbyone.tistory.com/48]

 

+

그냥 이유없이 들여쓰기 해서 블럭을 쓰고 싶은데 그렇게는 안되는 건가?

문법 수준에서 들여쓰기, 블럭으로 인식을 하다보니 임의의 블럭을 지정을 하지 못하게 하는 듯 하다.

'Programming > python(파이썬)' 카테고리의 다른 글

python exception  (0) 2020.01.02
python 컴파일하기 및 디컴파일?  (0) 2019.12.14
tensorflow, pytorch  (0) 2019.12.10
python pip 특정 버전설치 / 목록에서 설치  (0) 2019.09.09
python expat parseFile()  (0) 2019.06.24
Posted by 구차니

기계학습 좀 공부해보면서

흐름을 파악하고 어떤식으로 구체화 하는지 방법론을 좀 공부할 필요가 있어서 찾는 중

 

[링크 : https://pytorch.org/]

[링크 : https://skymind.ai/kr/wiki/compare-dl4j-tensorflow-pytorch]

[링크 : http://blog.naver.com/rlaghlfh/221494731829]

Posted by 구차니

requires.txt 이런걸로 패키지 목록이 있으면 -r 옵션을 통해 손쉽게 설치할 수 있다.

pip install -r 파일명

[링크 : https://kwonnam.pe.kr/wiki/python/pip]

 

== 버전으로 특정 버전을 설치할 수 있다.

pip install module==1.10

[링크 : https://antilibrary.org/1122]

'Programming > python(파이썬)' 카테고리의 다른 글

python indent  (0) 2019.12.13
tensorflow, pytorch  (0) 2019.12.10
python expat parseFile()  (0) 2019.06.24
ubuntu에서 python으로 postgres 접속하기  (0) 2019.06.24
python pip 특정 버전 설치하기  (0) 2019.06.18
Posted by 구차니