[提问]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如何高效完成?先谢谢各位了。
建议:别直接跟数据库比较。太耗费IO。
把你需要比较的字段从数据 ......
照着书上写的,执行时报错(Python2.6)
import wx
class InsertFrame(wx.Frame):
def __init__(self,parent,id):
wx.Frame.__init__(self,parent,id,'F ......
//下面的代码运行正常
tomstrs=re.findall(......)
mtxx=''
for tomstr in tomstrs:
tomstr=tomstr.strip()
if tomstr:
mtxx += tomstr ......