标签: reverse

如何在Go中反转字符串?

我们如何在Go中反转一个简单的字符串?

string reverse go

92
推荐指数
13
解决办法
5万
查看次数

正确的方法来反转pandas.DataFrame?

这是我的代码:

import pandas as pd

data = pd.DataFrame({'Odd':[1,3,5,6,7,9], 'Even':[0,2,4,6,8,10]})

for i in reversed(data):
    print(data['Odd'], data['Even'])
Run Code Online (Sandbox Code Playgroud)

当我运行此代码时,我收到以下错误:

Traceback (most recent call last):
  File "C:\Python33\lib\site-packages\pandas\core\generic.py", line 665, in _get_item_cache
    return cache[item]
KeyError: 5

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\*****\Documents\******\********\****.py", line 5, in <module>
    for i in reversed(data):
  File "C:\Python33\lib\site-packages\pandas\core\frame.py", line 2003, in __getitem__
    return self._get_item_cache(key)
  File "C:\Python33\lib\site-packages\pandas\core\generic.py", line 667, in _get_item_cache
    values = self._data.get(item)
  File "C:\Python33\lib\site-packages\pandas\core\internals.py", line 1656, in get
    _, block …
Run Code Online (Sandbox Code Playgroud)

python reverse pandas

91
推荐指数
5
解决办法
12万
查看次数

在Python中创建"反向"列表的最佳方法?

在Python中,创建新列表的最佳方法是什么,其列表的项目与其他列表的项目相同,但顺序相反?(我不想修改现有的列表.)

这是我遇到的一个解决方案:

new_list = list(reversed(old_list))
Run Code Online (Sandbox Code Playgroud)

也可以复制old_list然后反复复制到位:

new_list = list(old_list) # or `new_list = old_list[:]`
new_list.reverse()
Run Code Online (Sandbox Code Playgroud)

有没有更好的选择我忽略了?如果没有,是否有令人信服的理由(如效率)使用上述方法之一而不是另一种?

python reverse html-lists

85
推荐指数
3
解决办法
7万
查看次数

c#试图反转列表

public class CategoryNavItem
{
    public int ID { get; set; }
    public string Name { get; set; }
    public string Icon { get; set; }

    public CategoryNavItem(int CatID, string CatName, string CatIcon)
    {
        ID = CatID;
        Name = CatName;
        Icon = CatIcon;
    }
}

public static List<Lite.CategoryNavItem> getMenuNav(int CatID)
{
    List<Lite.CategoryNavItem> NavItems = new List<Lite.CategoryNavItem>();

    -- Snipped code --

    return NavItems.Reverse();
}
Run Code Online (Sandbox Code Playgroud)

反过来不起作用:

Error 3 Cannot implicitly convert type 'void' to 'System.Collections.Generic.List<Lite.CategoryNavItem>'

任何想法为什么会这样?

c# reverse list

85
推荐指数
5
解决办法
8万
查看次数

如何使用django urlresolvers反向传递GET参数

我正在使用django 1.2并使用urlresolvers反向方法从一个视图转到另一个视图.

url = reverse(viewOne)
Run Code Online (Sandbox Code Playgroud)

我想传递一个get参数,例如

name ='joe'

所以在视图中如果我这样做

def viewOne(request):
    request.GET['name']
Run Code Online (Sandbox Code Playgroud)

我会得到

joe
Run Code Online (Sandbox Code Playgroud)

我怎么做 ?

django reverse get

75
推荐指数
3
解决办法
3万
查看次数

如何使用UIPanGestureRecognizer捕获正在平移的方向?

好的,所以我一直在四处寻找太阳下用于捕捉多点触控手势的所有选项,我终于完成了一圈并回到了UIPanGestureRecognizer.

我想要的功能非常简单.我已经设置了一个双指平移手势,我希望能够根据我移动的像素数量来移动一些图像.我已经做得很好了,但我希望能够捕获平移手势是否已经反转.

有没有内置的方式,我只是没有看到回过头来做手势?我是否必须存储我的原始起点,然后跟踪终点,然后查看它们之后的移动位置,如果它小于初始终点,然后相应地反转?我可以看到工作,但我希望有一个更优雅的解决方案!

谢谢

编辑:

以下是识别器设置为触发的方法.它有点像黑客,但它有效:

-(void) throttle:(UIGestureRecognizer *) recognize{

throttleCounter ++;

if(throttleCounter == 6){
    throttleCounter = 0;
    [self nextPic:nil];
}

UIPanGestureRecognizer *panGesture = (UIPanGestureRecognizer *) recognize;
UIView *view = recognize.view;
if(panGesture.state == UIGestureRecognizerStateBegan){
    CGPoint translation = [panGesture translationInView:view.superview];
    NSLog(@"X: %f, Y:%f", translation.x, translation.y);
}else if(panGesture.state == UIGestureRecognizerStateEnded){
    CGPoint translation = [panGesture translationInView:view.superview];
            NSLog(@"X: %f, Y:%f", translation.x, translation.y);
}
  }
Run Code Online (Sandbox Code Playgroud)

我刚刚开始尝试跟踪值之间的差异......试着告诉他们正在淘汰的方式

iphone reverse capture pan uigesturerecognizer

58
推荐指数
3
解决办法
3万
查看次数

android - 反转数组的顺序

我有一个对象数组.

是否可以创建一个新数组,该数组是此数组的副本,但顺序相反?我在找这样的东西.

// my array
ArrayList<Element> mElements = new ArrayList<Element>();
// new array
ArrayList<Element> tempElements = mElements;

tempElements.reverse(); // something to reverse the order of the array
Run Code Online (Sandbox Code Playgroud)

arrays reverse android

54
推荐指数
1
解决办法
4万
查看次数

如何逆序向量?

假设我有一个向量v,我如何得到它的反向,即最后一个元素?

我遇到的第一件事是v[length(v):1],但是当它vnumeric(0),当它返回NA时,用户通常期望排序什么都不返回任何东西,没有排序什么都不会返回不可用的东西 - 它确实在我的情况下产生了很大的不同.

sorting reverse r vector

50
推荐指数
1
解决办法
5万
查看次数

Linux:查找给定"原始"文件的所有符号链接?(反向'readlink')

请考虑以下命令行代码段:

$ cd /tmp/
$ mkdir dirA
$ mkdir dirB
$ echo "the contents of the 'original' file" > orig.file
$ ls -la orig.file 
-rw-r--r-- 1 $USER $USER 36 2010-12-26 00:57 orig.file

# create symlinks in dirA and dirB that point to /tmp/orig.file:

$ ln -s $(pwd)/orig.file $(pwd)/dirA/
$ ln -s $(pwd)/orig.file $(pwd)/dirB/lorig.file
$ ls -la dirA/ dirB/
dirA/:
total 44
drwxr-xr-x  2 $USER $USER  4096 2010-12-26 00:57 .
drwxrwxrwt 20 root          root          36864 2010-12-26 00:57 ..
lrwxrwxrwx  1 $USER …
Run Code Online (Sandbox Code Playgroud)

linux bash symlink reverse

49
推荐指数
3
解决办法
5万
查看次数

如何反转String.fromCharCode?

String.fromCharCode(72)给出H.如何从char H获得数字72?

javascript reverse char

47
推荐指数
4
解决办法
3万
查看次数

标签 统计

reverse ×10

python ×2

android ×1

arrays ×1

bash ×1

c# ×1

capture ×1

char ×1

django ×1

get ×1

go ×1

html-lists ×1

iphone ×1

javascript ×1

linux ×1

list ×1

pan ×1

pandas ×1

r ×1

sorting ×1

string ×1

symlink ×1

uigesturerecognizer ×1

vector ×1