小编Ale*_*eri的帖子

从文本文件(Python)中的行读取specfic字符

char1= "P"
length=5
f = open("wl.txt", 'r')

for line in f:
if len(line)==length and line.rstrip() == char1:
   z=Counter(line)
   print z
Run Code Online (Sandbox Code Playgroud)

我想只输出长度= 5且包含字符p.So far的行

  f = open("wl.txt", 'r')
    for line in f:
    if len(line)==length :#This one only works with the length
      z=Counter(line)
      print z
Run Code Online (Sandbox Code Playgroud)

有人猜吗?

python

0
推荐指数
1
解决办法
126
查看次数

Javascript数组中的字符串

我的数组看起来像这样:

var imagetitle = new Array()
imagetitle[0] = "One two tree";
imagetitle[1] = "Zero One seven abc";
imagetitle[2] = "qwe qwe qwe";
imagetitle[3] = "rerere erere weqwe";
Run Code Online (Sandbox Code Playgroud)

Imagetitle稍后在HTML中用作标题.问题是,当我像这样使用它时,它只显示字符串的第一个字,而不是完整的字符串.

function showimage() {
var div_sa_slikom = document.createElement("div");
div_sa_slikom.innerHTML = "<a href="+imagetarget[i_image]+" title="+imagetitle[i_image]+" target='_parent'><img style='border:none;' src="+imageurl[i_image]+" border='0' title="+imagetitle[i_image]+" alt="+imagetitle[i_image]+" /></a>";
var container = document.getElementById("slike_rotator");
container.appendChild(div_sa_slikom);
}
Run Code Online (Sandbox Code Playgroud)

html javascript arrays string

0
推荐指数
1
解决办法
85
查看次数

使用Digest :: MD5在Perl中返回错误的MD5字符串

我试图用MD5加密这个字符串:

lolno
Run Code Online (Sandbox Code Playgroud)

我使用模块使用Digest :: MD5,我的输出是:

?;å?3Gù??? H?Gj?
Run Code Online (Sandbox Code Playgroud)

我知道这不是MD5所以我想问一下如何才能使这个工作?这是我使用的代码:

use Digest::MD5;
$ctx = Digest::MD5->new;
$ctx->add($pass);
$digest = $ctx->digest;
print $digest;
Run Code Online (Sandbox Code Playgroud)

我也尝试过:

use Digest::MD5 qw(md5);
$test = md5($pass);
print $test;
Run Code Online (Sandbox Code Playgroud)

perl md5

0
推荐指数
1
解决办法
482
查看次数

尝试打开gzip压缩文件时出现FileNotFoundException

所以,我正在尝试这个教程:http: //xjaphx.wordpress.com/2011/12/24/android-xml-adventure-parsing-xml-using-xpath/ 它工作得很好.我试图更改代码以适用于gzip压缩文件:

InputStream is = getResources().openRawResource(R.raw.data);
GZIPInputStream gz = new GZIPInputStream(is);
InputSource inputSrc = new InputSource(gz);
Run Code Online (Sandbox Code Playgroud)

但第一行抛出"java.io.FileNotFoundException:res/raw/data.xml.gz".我还尝试清理项目并将文件放在资产文件夹中并使用资产管理器打开它,但似乎没有任何工作.

xml android gzip filenotfoundexception

0
推荐指数
1
解决办法
442
查看次数

如何在C#中替换txt文件中的单词?

我正在尝试打开.txt文件,搜索一个单词并将其替换为出现的任何位置.我可以这样做,但不能用.txt文件只用我在文件中写的字符串.这.cs是我到目前为止的方法:

public void EditorialControl(string fileName, string word, string replacement)
    {            
        List<string> list = new List<string>();
        using (StreamReader reader = new StreamReader(directory + fileName))
        {
            string line;
            while ((line = reader.ReadLine()) != null)
            {                   
                Console.WriteLine(line);
                list.Add(line);
            }
            reader.Close();
        }
     }
Run Code Online (Sandbox Code Playgroud)

当我调用方法时Main(),它应该取参数word并用我选择的替换字替换它.

你能帮助我用代码替换方法中的单词吗?

c# methods replace streamreader

0
推荐指数
1
解决办法
2012
查看次数

Javascript - 需要识别包含更多的字符串,然后只需要2个括号标记()

我正在寻找一个特定的正则表达式,它将帮助我识别我的字符串是否只包含两种类型的字符 -

我需要的正则表达式应该标识特定字符串是否只包含括号字符 ( )

javascript regex jquery

-1
推荐指数
1
解决办法
329
查看次数

Symfony 错误 - 无法访问私有属性 AppBundle\Entity\VacancyEntity::$jobDescription

当我尝试访问 symfony 2.8 中的获取结果时,出现此错误。这是我的代码

 public function staticAction(Request $request)
    {   


      $jobid = $this->get('session')->get('jobid');
      $jobDetails = $this->getVacancyData($jobid);
      echo "<pre>";
      var_dump($jobDetails);
      $description = $jobDetails->jobDescription;


      return $this->render('FrontEnd/job.html.twig', array('jobdetails' => $jobDetails ));
    }

    public function getVacancyData($id){

        $vacancy = $this->getDoctrine()
        ->getRepository(VacancyEntity::class)
        ->findOneBy(array('id' => $id));


        if (!$vacancy) {
            throw $this->createNotFoundException();
        }else{
            return $vacancy;
        }  

    }
Run Code Online (Sandbox Code Playgroud)

以下行发生错误,

$description = $jobDetails->jobDescription;
Run Code Online (Sandbox Code Playgroud)

怎么解决这个问题呢?

php doctrine symfony symfony-2.8

-1
推荐指数
1
解决办法
5394
查看次数