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

  1. 2018.04.04 pypy
  2. 2017.04.02 파이썬 print가 희한하네..
  3. 2017.04.02 파이썬 리스트(list)와 튜플(tuple)
  4. 2017.04.02 파이썬 type 확인하기
  5. 2017.03.30 python sqlite3
  6. 2016.12.30 python smtplib의 신비..?
  7. 2014.03.19 python이 인기라는데..
  8. 2013.01.02 python2 vs python3
  9. 2011.10.04 PyOpenGL
  10. 2011.09.13 python 3.2.2 64bit 버전 설치 4

예전에 적은게 있나 모르겠다만

그냥 생각나서 라즈베리에서 쳐보니까

기본으로 패키지 통합된 듯


pi@raspberrypi:~ $ python

Python 2.7.9 (default, Sep 17 2016, 20:26:04)

[GCC 4.9.2] on linux2

Type "help", "copyright", "credits" or "license" for more information.

>>> exit() 


pi@raspberrypi:~ $ pypy

Python 2.7.10 (4.0.1+dfsg-1+rpi1, Mar 07 2016, 10:36:18)

[PyPy 4.0.1 with GCC 4.9.2] on linux2

Type "help", "copyright", "credits" or "license" for more information.

>>>> exit() 


pi@raspberrypi:~ $ which python

/usr/bin/python

pi@raspberrypi:~ $ which pypy

/usr/bin/pypy

pi@raspberrypi:~ $ ll /usr/bin/pypy

lrwxrwxrwx 1 root root 22 Mar  8  2016 /usr/bin/pypy -> ../lib/pypy/bin/pypy-c

pi@raspberrypi:~ $ ll /usr/lib/pypy/bin

total 32604

drwxr-xr-x 2 root root     4096 Nov 26  2016 .

drwxr-xr-x 8 root root     4096 Nov 26  2016 ..

-rwxr-xr-x 1 root root 33374512 Mar  8  2016 pypy-c


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

python + openGL  (0) 2019.04.30
python + openCV 공부 시작  (0) 2019.04.30
파이썬 print가 희한하네..  (0) 2017.04.02
파이썬 리스트(list)와 튜플(tuple)  (0) 2017.04.02
파이썬 type 확인하기  (0) 2017.04.02
Posted by 구차니

망할(!) 유니코드 ㅠㅠ

sqlite의 내용이 utf-8일텐데 아무튼.. 이걸 받아서 print 하니

죄다 u'\u' 이런식으로 유니코드 문자열을 알려주는 접두와 16진수로만 출력이 된다

그래서 이걸 정상적으로 출력하는걸 찾아보는데

간편하게 출력하는건 없고.. 파이썬 print 함수의 특징으로 봐야 하려나?


튜플,리스트 단위로 출력하면 escape 된 채로

항목 하나만 출력하면 정상적으로 한글로 나온다.

도대체 머야?!


아무튼 아래와 같이 하면 정상출력되긴 한다.( u' ' 접두는 붙는다.)

print repr(a).decode("unicode-escape") 

[링크 : http://stackoverflow.com/.../python-print-unicode-strings-in-arrays-as-characters-not-code-points]

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

python + openCV 공부 시작  (0) 2019.04.30
pypy  (0) 2018.04.04
파이썬 리스트(list)와 튜플(tuple)  (0) 2017.04.02
파이썬 type 확인하기  (0) 2017.04.02
python sqlite3  (0) 2017.03.30
Posted by 구차니

튜플은 (1,2,3) 식으로 출력되고

리스트는 [1,2,3] 식으로 출력된다.


다만 내용적으로는 리스트는 순서가 변할수 있으며(순서가 의미가 없다)

튜플은 순서를 바꿀수 없다(즉, 순서에 의미가 있다)


4.6.5. Tuples

Tuples are immutable sequences, typically used to store collections of heterogeneous data (such as the 2-tuples produced by the enumerate() built-in). Tuples are also used for cases where an immutable sequence of homogeneous data is needed (such as allowing storage in a set or dict instance). 

[링크 : https://docs.python.org/3/library/stdtypes.html#tuples]


4.6.4. Lists

Lists are mutable sequences, typically used to store collections of homogeneous items (where the precise degree of similarity will vary by application). 

[링크 : https://docs.python.org/3/library/stdtypes.html#lists]

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

pypy  (0) 2018.04.04
파이썬 print가 희한하네..  (0) 2017.04.02
파이썬 type 확인하기  (0) 2017.04.02
python sqlite3  (0) 2017.03.30
python smtplib의 신비..?  (0) 2016.12.30
Posted by 구차니


type(변수명) 


참 쉽네...

[링크 : http://chouingchou.tistory.com/53]

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

파이썬 print가 희한하네..  (0) 2017.04.02
파이썬 리스트(list)와 튜플(tuple)  (0) 2017.04.02
python sqlite3  (0) 2017.03.30
python smtplib의 신비..?  (0) 2016.12.30
python이 인기라는데..  (0) 2014.03.19
Posted by 구차니

python에서 sqlite 파일을 접속해서 조작하는 방법


$ sudo apt-get install python-sqlite

Reading package lists... Done

Building dependency tree

Reading state information... Done

The following extra packages will be installed:

  libsqlite0

Suggested packages:

  python-sqlite-dbg

The following NEW packages will be installed:

  libsqlite0 python-sqlite

0 upgraded, 2 newly installed, 0 to remove and 7 not upgraded.

Need to get 141 kB of archives.

After this operation, 519 kB of additional disk space will be used.

Do you want to continue? [Y/n]

Get:1 http://mirrordirector.raspbian.org/raspbian/ jessie/main libsqlite0 armhf 2.8.17-12 [119 kB]

Get:2 http://mirrordirector.raspbian.org/raspbian/ jessie/main python-sqlite armhf 1.0.1-11 [21.3 kB]

Fetched 141 kB in 1s (95.8 kB/s)

Selecting previously unselected package libsqlite0.

(Reading database ... 137326 files and directories currently installed.)

Preparing to unpack .../libsqlite0_2.8.17-12_armhf.deb ...

Unpacking libsqlite0 (2.8.17-12) ...

Selecting previously unselected package python-sqlite.

Preparing to unpack .../python-sqlite_1.0.1-11_armhf.deb ...

Unpacking python-sqlite (1.0.1-11) ...

Setting up libsqlite0 (2.8.17-12) ...

Setting up python-sqlite (1.0.1-11) ...

Processing triggers for libc-bin (2.19-18+deb8u7) ...


pi@raspberrypi:~ $ cd src

pi@raspberrypi:~/src $ ll

total 2060

drwxr-xr-x  2 pi pi    4096 Mar 30 14:40 .

drwxr-xr-x 30 pi pi    4096 Mar 30 14:34 ..

-rw-r--r--  1 pi pi 2099200 Mar 29 12:29 sqlite.udb


pi@raspberrypi:~/src $ python

Python 2.7.9 (default, Sep 17 2016, 20:26:04)

[GCC 4.9.2] on linux2

Type "help", "copyright", "credits" or "license" for more information.

>>> import sqlite3

>>> conn = sqlite3.connect('sqlite.udb')

>>> c = conn.cursor()

>>> c.execute("select * from tbl_recv")

<sqlite3.Cursor object at 0x769eaa20> 


데이터가 유니코드로 나오나..

# we can also implement a custom text_factory ...

# here we implement one that will ignore Unicode characters that cannot be

# decoded from UTF-8

con.text_factory = lambda x: unicode(x, "utf-8", "ignore") 


[링크 : https://docs.python.org/2/library/sqlite3.html]

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

파이썬 리스트(list)와 튜플(tuple)  (0) 2017.04.02
파이썬 type 확인하기  (0) 2017.04.02
python smtplib의 신비..?  (0) 2016.12.30
python이 인기라는데..  (0) 2014.03.19
python2 vs python3  (0) 2013.01.02
Posted by 구차니

어라?

파이썬으로 메일보내는데

새가

ㅅㅐ 로 보내지네.. 머지?


[링크 : http://unicode.scarfboy.com/?s=U%2BC0C8]

[링크 : http://unicode.scarfboy.com/?s=U%2b1109]

[링크 : http://unicode.scarfboy.com/?s=U%2b1162]



+

설정해도 안되고..

일단 ssh에서 직접 스크립트를 실행하면 한글이 안깨지고 가는데..

svn 통해서 hook 실행되면 깨진다.

[링크 : https://mikewest.org/2006/06/subversion-post-commit-hooks-101]

[링크 : http://svnbook.red-bean.com/nightly/en/svn.reposadmin.create.html#svn.reposadmin.create.hooks]

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

파이썬 type 확인하기  (0) 2017.04.02
python sqlite3  (0) 2017.03.30
python이 인기라는데..  (0) 2014.03.19
python2 vs python3  (0) 2013.01.02
PyOpenGL  (0) 2011.10.04
Posted by 구차니
한동안 죽어있다가 이제야 조금 살아나는 기미가 보이긴 한데
학원이나 아는 사람들에게 이야기를 들으면
요즘 각광받는 언어라고 해서 참으로 의아한..

python2 2.7.x 에서 한동안 3.x 대로의 이전이 쉽지 않았는지 거의 3년 가량을 죽어 있다가
2014년 3월 16일 3.4.0이 릴리즈 된 걸 봐서는 이제 이 언어도 살아 날지도 모르겠다.

[링크 : https://www.python.org/download/releases/]

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

python sqlite3  (0) 2017.03.30
python smtplib의 신비..?  (0) 2016.12.30
python2 vs python3  (0) 2013.01.02
PyOpenGL  (0) 2011.10.04
python 3.2.2 64bit 버전 설치  (4) 2011.09.13
Posted by 구차니
파이썬 2.7과 파이썬 3.3 두가지 버전이 있어서 무슨 차이가 있나 찾아보니
2.7이후로는 업데이트도 하지 않을 것이기에 3.3을 쓰라고 되어 있다.

2.x에서 3.x으로 이전하게 된 이유가
과거의 잘못 구현된 부분을 바로잡기 위함이기에
5년 정도의 이전기간을 고려하고 있다고 하는데
다르게 말하면 한동안 2.7을 사용해야만 하고
나중에 3.x대로 이전을 반드시 해야 하지만 그동안 언어가 살아있을지도 조금 의문이 되는 상황...

[링크 : http://wiki.python.org/moin/Python2orPython3]
[링크 : http://docs.python.org/3/whatsnew/3.0.html]

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

python smtplib의 신비..?  (0) 2016.12.30
python이 인기라는데..  (0) 2014.03.19
PyOpenGL  (0) 2011.10.04
python 3.2.2 64bit 버전 설치  (4) 2011.09.13
python 버전 골라서 실행하기  (0) 2011.05.08
Posted by 구차니
Python의 openGL 바인딩이다.
linux 개발용 노트북을 해놔서 C를 통해 개발을 해도 상관은 없지만
다른 언어도 배울겸 한번 openGL을 python으로 하면 어떨까? 싶어서 찾아본 내용인데 흐음..
함수 이름이라던가 거의 100% C와 동일한데 별 의미가 없으려나?

import OpenGL 
from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.GLUT import * 

[링크 : http://pyopengl.sourceforge.net/]
[링크 : http://pypi.python.org/pypi/PyOpenGL-Demo] demo 

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

python이 인기라는데..  (0) 2014.03.19
python2 vs python3  (0) 2013.01.02
python 3.2.2 64bit 버전 설치  (4) 2011.09.13
python 버전 골라서 실행하기  (0) 2011.05.08
python C/api - PyObject_GetAttrString()  (0) 2010.04.06
Posted by 구차니
이유는 모르겠지만 Windows7 Ultimate 64bit 버전에서 윈도우즈 업데이트를 진행하며 실행하니 오류가 발생했다.
리부팅하고 나니 문제없이 넘어가서 대략 황당 -ㅁ-


 

 

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

python2 vs python3  (0) 2013.01.02
PyOpenGL  (0) 2011.10.04
python 버전 골라서 실행하기  (0) 2011.05.08
python C/api - PyObject_GetAttrString()  (0) 2010.04.06
파이썬 문자열 쌍따옴표 세개 - """ python string  (0) 2010.04.04
Posted by 구차니