[ÌáÎÊ]Python ÈçºÎºöÂÔ whitespace ¶ÁÈë
Ïñ C µÄ scanf() ÄÇÑù
±ÈÈç¶ÁÈë 1 2 3 a b c
ÿ´Î¶ÁÈëÒ»¸ö
ÏÂÃæÕâ¸öÓ¦¸ÃÊÇÄãÏëÒªµÄ°É£º
Python code:
>>> k = raw_input()
0 0123 ds dsl sd
>>> k
'0 0123 ds dsl sd'
>>> k.split(' ')
['0', '0123', 'ds', 'dsl', 'sd']
>>>
LSµÄ»Ø´ð²»´í
²»ÖªµÀpythonÓÐûÓÐÏֳɵĺ¯Êý¿ÉÒÔµ÷ÓÃ
×ÜËã·¢ÏÖÁ˽â¾ö·½·¨
ʹÓà ctypes ¿â
from ctypes import *
libc = CDLL('libc.so.6')
a = c_int()
b = c_double()
c = c_char()
s = create_string_buffer(100)
libc.scanf('%c%d%lf%s', byref(c), byref(a), byref(b), byref(s))
print c.value, a.value, b.value, s.value
43842050 Python,c/c++Ⱥ£¬ÓÐÖ¾ÏëѧPython,CºÍC++µÄÅóÓÑÇë¼ÓÈëȺ¡£
Ïà¹ØÎÊ´ð£º
ÎÒÏÖÔÚÊÇÕâÑùµÄ
¿ªÁËÒ»¸ö×ÓỊ̈߳¬¶ÁÈ¡ÏÂÃæµÄÏûÏ¢
±¾ÒâÊÇ
Python code:
while not self._stopevent.isSet( ):
re=¶ÁȡϲãÏûÏ¢
if re>0:
´¦Àí
else:
pass
¼ÙÈ ......
±¾ÎÄÕª×Ô¡¶¿É°®µÄPython¡·¡°¹âÅ̹ÊÊ¡±CDay-1 ʵÓû¯ÖÐÎÄ¡£
[img]http://t.douban.com/mpic/s3901817.jpg[/img]
CDay-1 ʵÓû¯ÖÐÎÄÖÐÎÄ´¦Àí£¬Íê³É¹¦ÄܵÄʵÓû¯
ÄãÅöµ½99%µÄÎÊÌ⣬ÆäËûÈË֮ǰÒѾÓöµ½¹ýÁË£¬Ë ......
1. os.system
Python code:
import os
import tempfile
filename1 = tempfile.mktemp (".txt")
open (filename1, "w").close ()
filename2 = filename1 + ".copy"
print fi ......
ÈçÌ⣬
¡¶pythonÔ´ÂëÆÊÎö¡·ÖеÚ32Ò³£¬
Óиö¼ì²é¼Ó·¨½á¹ûÊÇ·ñÒç³öµÄ´úÂ룬
´óÖÂÈçÏ£º
C/C++ code:
long a, b, x;
x = a + b;
//¼ì²é½á¹ûÊÇ·ñÒç³ö
if((x^a)>=0 || (x^b)>=0)
return OK; // ......