python可以支持short或int的序列吗? [英] does python could support sequence of short or int?
问题描述
有没有办法让python按int或short的顺序运行?
在C中,我们只需要声明一个点,然后我就可以得到点值,
就像:
short * k =缓冲区,// k是指向短序列点的点。
short i = * k ++,
但是python是一种动态语言,
a =缓冲区
i =?我不知道怎么继续,这是什么? a似乎是一个str?
is there a way to let python operate on sequence of int or short?
In C, we just need declare a point, then I could get the point value,
just like:
short* k = buffer, //k is a point to a sequence point of short.
short i = *k++,
but python is a dynamic language,
a = buffer
i = ? I don''t know how to continue, what''s a? a seems to be a str?
推荐答案
momobear schrieb:
momobear schrieb:
有没有办法让python按int或short的顺序操作?
在C中,我们只需要声明一个点,然后我就可以获得点值,
就像:
short * k = buffer,/ / k是一个短序列点。
short i = * k ++,
但python是一种动态语言,
a = buffer
i =?我不知道怎么继续,这是什么? a似乎是一个str?
is there a way to let python operate on sequence of int or short?
In C, we just need declare a point, then I could get the point value,
just like:
short* k = buffer, //k is a point to a sequence point of short.
short i = *k++,
but python is a dynamic language,
a = buffer
i = ? I don''t know how to continue, what''s a? a seems to be a str?
你应该阅读python教程,特别是关于列表的部分,
元组和dicts。 />
http://docs.python.org/tut/
Diez
You should read the python tutorial, especially the parts about list,
tuples and dicts.
http://docs.python.org/tut/
Diez
momobear写道:
momobear wrote:
有没有办法让python运行在int或short的序列中?
在C中,我们只需要声明一个点,
我假设你的意思是''指针''。
然后我可以获得点值,
就像:
short * k = buffer,// k是一个指向短序列点的点。
short i = * k ++,
但是python是一种动态语言,
a = buffer
i =?我不知道怎么继续,这是什么? a似乎是一个str?
is there a way to let python operate on sequence of int or short?
In C, we just need declare a point,
I assume you mean a ''pointer''.
then I could get the point value,
just like:
short* k = buffer, //k is a point to a sequence point of short.
short i = *k++,
but python is a dynamic language,
a = buffer
i = ? I don''t know how to continue, what''s a? a seems to be a str?
< meta>
你可能会通过暴露问题得到更好的答案''重新尝试
来解决而不是你认为的解决方案
< / meta>
无论如何,如果你想要一个整数列表,只需将整数放入一个列表
并迭代该列表:
buffer = [1,2,3,42]
for i in buffer:
do_something_with(i)
-
bruno desthuilliers
python -c" print''@''。join([''。''。join([w [:: - 1] for w in p.split(''。'')])for br /'
p in''o **** @ xiludom.gro''。split(''@'')])"
<meta>
You''d probably get better answers by exposing the problem you''re trying
to solve instead of what you think is the solution
</meta>
Anyway, if you want a list if integers, just put integers into a list
and iterate over that list:
buffer = [1, 2, 3, 42]
for i in buffer:
do_something_with(i)
--
bruno desthuilliers
python -c "print ''@''.join([''.''.join([w[::-1] for w in p.split(''.'')]) for
p in ''o****@xiludom.gro''.split(''@'')])"
但是关于缓冲区不是在python程序中声明的,它来自C函数的
。那我想把一个字符串视为一个短的
列表呢?
buffer = foobur()//来自C函数的调用,它被封装成一个
string
但是我想把它当作一个短名单。我该怎么办?
but what about buffer is not be declared in python program, it comes
from a C function. and what about I want to treat a string as a short
list?
buffer = foobur() // a invoke from C function, it is encapsulated as a
string
but I want to treat it as a short list. how can I?
这篇关于python可以支持short或int的序列吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!