특수한 변수명

 

1. _string 형태

from module import * 구문에서 import되지 않는다.

interactive한 환경에서는 마지막 expression(표현식)의 결과를 보전하고 있다.

 

2. __string__

시스템에서 정의하는 이름으로 특별한 의미를 갖는다. 사용자는 이러한 형태로 변수명을 만들면 안된다.

 

3. __string

enclosing class에 국한되는 변수들

 

변수명을 짓는 습관

1. 클래스명은 대문자로 시작

2. 모듈명은 소문자로 시작

 

'Python' 카테고리의 다른 글

iteration, iterable, iterator  (0) 2019.12.27
( ) = ( ) if ( ) else ( ) 구문  (0) 2019.12.27
python statements  (0) 2019.12.27
binary data pack unpack examples  (0) 2019.12.27
struct : binary data packing & unpacking options  (0) 2019.12.27

파이선 프로그램은 module들로 이루어져 있으며, module 안에는 statement들이 있고, statement는 expression을 포함하고 있다.

 

파이선 statements 의 종류

1. assignment

2. calls

3. print calls

4. if/elif/else

5. for

6. while

7. pass

8. break

9. continue

10. def

11. return

12. yield

13. global

14. nonlocal

15. import

16. from

17. class

18. try/except/finally

19. raise

20. assert

21. with as

22. del

 

'Python' 카테고리의 다른 글

( ) = ( ) if ( ) else ( ) 구문  (0) 2019.12.27
변수명  (0) 2019.12.27
binary data pack unpack examples  (0) 2019.12.27
struct : binary data packing & unpacking options  (0) 2019.12.27
list comprehension과 for loop 벤치  (0) 2019.12.27

In [15]: f=open('bdata.bin','wb')

 

In [16]: data=struct.pack('>i5sh',50,b'email',4)

 

In [17]: f.write(data)

Out[17]: 11

 

In [18]: f.close()

 

In [19]: f=open('bdata.bin','rb')

 

In [20]: data2=f.read()

 

In [21]: data2

Out[21]: b'\x00\x00\x002email\x00\x04'

 

In [22]: orgdata=struct.unpack('>i5sh',data2)

 

In [23]: orgdata

Out[23]: (50, b'email', 4)

 

'Python' 카테고리의 다른 글

( ) = ( ) if ( ) else ( ) 구문  (0) 2019.12.27
변수명  (0) 2019.12.27
python statements  (0) 2019.12.27
struct : binary data packing & unpacking options  (0) 2019.12.27
list comprehension과 for loop 벤치  (0) 2019.12.27

+ Recent posts