Setting Up Your Development Environment(Chapter 1 of Gray Hat Python)
2011-04-02 19:50
465 查看
1 >>> from ctypes import *
2 >>> c_int()
3 c_long(0)
4 >>> c_char_p("hello world!")
5 c_char_p('hello world!')
6 >>> c_ushort(-5)
7 c_ushort(65531)
8 >>> seitz = c_char_p("loves python")
9 >>> print seitz
c_char_p('loves python')
>>> print seitz.value
loves python
from ctypes import *
msvcrt = cdll.msvcrt
message_string = "Hello world!\n"
msvcrt.printf("Testing: %s", message_string)
1 from ctypes import *
2
3 class barley_amount(Union):
4 _fields_ = [
5 ("barley_long", c_long),
6 ("barley_int", c_int),
7 ("barley_char", c_char * 8),
8 ]
9
value = raw_input("Enter the amount of barley of put into the beer vat:")
my_barley = barley_amount(int(value))
print "Barley amount as a long: %ld" % my_barley.barley_long
print "Barley amount as a int: %d" % my_barley.barley_int
print "Barley amount as a char: %s" % my_barley.barley_char
2 >>> c_int()
3 c_long(0)
4 >>> c_char_p("hello world!")
5 c_char_p('hello world!')
6 >>> c_ushort(-5)
7 c_ushort(65531)
8 >>> seitz = c_char_p("loves python")
9 >>> print seitz
c_char_p('loves python')
>>> print seitz.value
loves python
from ctypes import *
msvcrt = cdll.msvcrt
message_string = "Hello world!\n"
msvcrt.printf("Testing: %s", message_string)
1 from ctypes import *
2
3 class barley_amount(Union):
4 _fields_ = [
5 ("barley_long", c_long),
6 ("barley_int", c_int),
7 ("barley_char", c_char * 8),
8 ]
9
value = raw_input("Enter the amount of barley of put into the beer vat:")
my_barley = barley_amount(int(value))
print "Barley amount as a long: %ld" % my_barley.barley_long
print "Barley amount as a int: %d" % my_barley.barley_int
print "Barley amount as a char: %s" % my_barley.barley_char
相关文章推荐
- The General Procedure Of Setting Up EDKII Development Environment:搭建EDKII开发环境的通用流程[2.1]
- storm环境搭建(前言)—— 翻译 Setting Up a Development Environment
- set up Android development environment and python
- Storm Setting Up a Development Environment
- Setting Up the Development Environment for SharePoint 2010 on Windows Vista,
- Expert Oracle Database Architecture学习笔记之:Setting Up Your Environment
- Setting up a Keystone development environment
- Setting up storm development environment
- Setting up Pinax development environment on Eclipse.
- Setting Up Your Environment
- Tutorial: Setting up the Python/Jython Environment for Burp Suite
- Openstack 1:配置开发环境 Setting Up a Development Environment
- Setting up a DFC Development Environment in Eclipse
- Setting Up the Development Environment for SharePoint 2010 on Windows Vista, Windows 7, and Windows
- Setting up an RTEMS development environment for the Raspberry Pi
- Setting up an extension development environment
- Setting Up Your Own ASP Development Templates
- Programming in Go (Golang) – Setting up a Mac OS X Development Environment
- Setting Up Your Build phoneME Feature Environment (MR4)