[提问]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++的朋友请加入群。
相关问答:
麻烦高手解答一下 谢谢了 我是新手 一些概念都不太清楚。。。
pyodbc is a Python module that allows you to use ODBC to connect to almost any database from Windows, Linux, OS/X, and more.
pyodbc是 ......
喜欢Python的朋友请进.
详细信息请查看:
http://blog.csdn.net/lgg201/archive/2009/10/08/4643635.aspx
Let's-python-系列视频发布专贴 收藏
视频较早的时候就说是要录了, 这一周录了 ......
//下面的代码运行正常
tomstrs=re.findall(......)
mtxx=''
for tomstr in tomstrs:
tomstr=tomstr.strip()
if tomstr:
mtxx += tomstr ......
刚接触,感觉功能比较强大,主要是粘合性好,可以有机结合其他语言。但不明白它主要应用于什么领域,主要做那方面的东东。开发ERP系统是否可行?
基本上什么都可以做
今天去看了一下,基本上什么 ......
请问下,我的是python2.5安装了PIL模块,然后编写程序打开本机上的一个图片时,为什么老出现错误呢,老是找不到图片,错误提示如下:File "C:\Python25\Lib\site-packages\PIL\Image.py", line 1888, in o ......