我有一个python列表,其中包含1000个.就像是:
data=["I","am","a","python","programmer".....]
Run Code Online (Sandbox Code Playgroud)
其中,len(数据)=说1003
我现在想通过将原始列表拆分为100个块来创建此列表(数据)的子集.所以,最后,Id喜欢有类似的东西:
data_chunk1=[.....] #first 100 items of list data
data_chunk2=[.....] #second 100 items of list data
.
.
.
data_chunk11=[.....] # remainder of the entries,& its len <=100, len(data_chunk_11)=3
Run Code Online (Sandbox Code Playgroud)
是否有一种pythonic方式来完成这项任务?显然我可以使用数据[0:100]等等,但我认为这非常非pythonic且非常低效.
非常感谢.
我有从DB字符串url中获取的变量,但是url中没有引号,因此我需要在其下面添加引号。
var audioUrl
url is having string like http://xxxxx/xxx/xx-xx-123.m4a without double quotes
audioUrl= (data.url)
i need convert data.url value to "http://xxxxx/xxx/xx-xx-123.m4a"
Circle Jplayer
var audio="http://xxxxx/xxx/xx-xx-123.m4a"
var myOtherOne = new CirclePlayer("#jquery_jplayer_2",
{
m4a: audio,
}
Run Code Online (Sandbox Code Playgroud)