小编cpp*_*ppb的帖子

使用Selenium和Python定位,在文本框中输入值

<div class="MY_HEADING_A">
    <div class="TitleA">My title</div>
    <div class="Foobar"></div>
        <div class="PageFrame" area="W">                
             <span class="PageText">PAGE <input id="a1" type="txt" NUM="" />  of <span id="MAX"></span> </span>
</div>
Run Code Online (Sandbox Code Playgroud)

我有上面的代码,我试图使用selenium输入NUM上面的值这是我写的代码:

head = driver.find_element_by_class_name("MY_HEADING_A")
frame_elem = head.find_element_by_class_name("PageText")

# Following is a pseudo code. 
# Basically I need to enter a value of 1, 2, 3 etc in the textbox field (NUM) 
# and then hit RETURN key.
## txt  = frame_elem.find_element_by_name("NUM")
## txt.send_keys(Key.4"
Run Code Online (Sandbox Code Playgroud)

如何获取此元素并输入值?

python html-input form-submit python-2.7 selenium-webdriver

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

在python中将列表指定为命令行参数

我使用getopt来处理命令行可选参数,它应该接受一个列表.像这样的东西:

foo.py --my_list=[1, 2, 3, 4,5] 
Run Code Online (Sandbox Code Playgroud)

但是这会在"[1"之后修剪一切

我的问题是:A)有没有办法指定列表而不将其转换为字符串?(使用getopt)

B)如果我要将列表转换为字符串,如何将此列表转换为字符串?例如像mylist.split("?")之类的东西摆脱方括号?有没有更好的办法?

谢谢

python

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

使用Python的函数返回值为shell变量赋值

我有一个Python函数,fooPy()返回一些值.(int/double或string)

我想使用此值并将其分配给shell脚本.例如以下是python函数:

def fooPy():
    return "some string" 
    #return 10  .. alternatively, it can be an int

fooPy()
Run Code Online (Sandbox Code Playgroud)

在shell脚本中,我尝试了以下内容,但它们都不起作用.

fooShell = python fooPy.py
#fooShell = $(python fooPy.py)
#fooShell = echo "$(python fooPy.py)"
Run Code Online (Sandbox Code Playgroud)

python shell

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

如何获取二进制文件的幻数

每个二进制文件都有一个幻数,有人知道如何从文件中检索这些信息吗?

unix file-type magic-numbers

9
推荐指数
2
解决办法
2万
查看次数

使用PIL在Python中进行图像压纹 - 增加深度,方位角等

我正在尝试使用PIL压印图像.

PIL提供了一种压印图像的基本方法(使用ImageFilter.EMBOSS).

在像GIMP这样的图像编辑软件包中,您可以更改此浮雕图像中的方位角,深度和高程等参数.

如何用PIL做到这一点?至少我想调整浮雕图像的"深度".

更新:我尝试了Paul建议的东西(修改了filterargs这样的scale, offset和矩阵),但我无法改变"深度"效果.所以还在寻找答案.

这是使用PIL(左)和GIMP(右)的压花效果的比较.原始图片位于http://www.linuxtopia.org/online_books/graphics_tools/gimp_advanced_guide/gimp_guide_node74.html.

替代文字

python image-processing python-imaging-library

6
推荐指数
1
解决办法
3588
查看次数

使用Python 2.6在Windows上安装Pymedia

我试图从源代码安装最新版本的Pymedia.我有Python2.6并且没有可用的二进制文件.

开始于:

python setup.py build
Run Code Online (Sandbox Code Playgroud)

并得到以下消息:

Using WINDOWS configuration...
Path for  OGG not found.
Path for  VORBIS not found.
Path for  FAAD not found.
Path for  MP3LAME not found.
Path for  VORBISENC not found.
Path for  ALSA not found.
Continue building pymedia ? [Y,n]:Y
Run Code Online (Sandbox Code Playgroud)

把OGG和VORBIS的源代码放在我放了pymedia源代码的目录后,就可以找到那些库但是当我把源代码libmp3lame-3.95放在那个目录中时,它找不到它.

在阅读了pymedia的setup.py文件之后,我也尝试在libmp3lame/Release下为这个库添加一个dll,但它仍然无法找到它.

有人可以帮忙吗?是否有使用Python 2.6或更高版本的Pymedia二进制发行版?

python

6
推荐指数
2
解决办法
4238
查看次数

通过调用Fortran中的C++函数将Fortran int数组传递给C++

我试图在Fortran子例程中调用C++函数.该C++函数应该更新整数数组.这是我写的一个非工作代码.有什么问题?

! Fortran function that calls a C++ function.

subroutine my_function()

      integer(4) ar(*)

      integer(4) get_filled_ar

      ! Need correct syntax here.
      ar = get_filled_ar()
end


// C++ function:

    extern "C" {
        void get_filled_ar(int *ar){
            ar[0] = 1;
            ar[1] = 10;
            ar[3] = 100;
        }
    }
Run Code Online (Sandbox Code Playgroud)

c++ fortran

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

预定义大小的静态数组中的元素数

我有这样一个数组:

int a[100]; 
Run Code Online (Sandbox Code Playgroud)

我只填充此数组中的前4个元素:

a[0] = 1;
a[1] = 2;
a[2] = 3;
a[3] = 4;
Run Code Online (Sandbox Code Playgroud)

当我这样做sizeof(a)/sizeof(a[0]) 时返回100.

有没有办法可以获得我已经为其赋值的元素数量,从而过滤掉剩余的96个未分配元素?

谢谢

c++ arrays

4
推荐指数
2
解决办法
2048
查看次数

如何使用gstreamer从较长源的片段制作音频片段?

我想使用gstreamer将任意剪辑从一个音频文件保存到新文件.例如,原始的1分钟到2分钟的片段.我该怎么做?

python audio audio-streaming gstreamer segment

3
推荐指数
1
解决办法
2136
查看次数

使用3个组件创建一个numpy向量

我想使用3个组件Vx,Vy,Vz在numpy中创建一个向量,如下所示.有人可以帮忙吗?谢谢

from numpy import cos, sin

Vx = cos(alpha)* cos(beta)
Vy = sin(alpha)*cos(beta)
Vz = sin(beta)
Run Code Online (Sandbox Code Playgroud)

python numpy

2
推荐指数
1
解决办法
9636
查看次数