问题列表 - 第37166页

为什么Mercurial的ssh:// URL在路径前使用两个斜杠?

示例Mercurial URL: ssh://myhost//path/to/repo

为什么两个斜杠?主机名已指定.为什么它不起作用http://myhost/path/to/page只有一个斜线就足够了?

url mercurial

5
推荐指数
2
解决办法
2736
查看次数

如何使用XSLT包装一组相邻元素?

我有一些带<ListItem>元素的XML ,我想用<List>元素包装任何连续的运行.因此,源XML看起来像这样:

<Section>
  <Head>Heading</Head>
  <Para>Blah</Para>
  <ListItem>item 1</ListItem>
  <ListItem>item 2</ListItem>
  <ListItem>item 3</ListItem>
  <ListItem>item 4</ListItem>
  <Para>Something else</Para>
</Section>
Run Code Online (Sandbox Code Playgroud)

我想把它转换成这样的东西:

<Section>
  <Head>Heading</Head>
  <Para>Blah</Para>
  <List>
    <ListItem>item 1</ListItem>
    <ListItem>item 2</ListItem>
    <ListItem>item 3</ListItem>
    <ListItem>item 4</ListItem>
  </List>
  <Para>Something else</Para>
</Section>
Run Code Online (Sandbox Code Playgroud)

使用XSLT.我确信这很明显,但我不能在晚上的这个时候解决这个问题.谢谢!


编辑:大多数人都可以安全地忽略这一点.

这个XML:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Root>
  <Story>
    <Section id="preface">
      <ChapterTitle>Redacted</ChapterTitle>
      <HeadA>Redacted</HeadA>
      <Body>Redacted</Body>
      <BulletListItem>Item1</BulletListItem>
      <BulletListItem>Item2</BulletListItem>
      <BulletListItem>Item3</BulletListItem>
      <BulletListItem>Item4</BulletListItem>
      <HeadA>Redacted</HeadA>
      <Body>Redacted</Body>
      <HeadA>Redacted</HeadA>
      <Body>Redacted</Body>
      <Body>Redacted<Italic>REDACTED</Italic>Redacted</Body>
      <BulletListItem>Second list Item1</BulletListItem>
      <BulletListItem>Second list Item2</BulletListItem>
      <BulletListItem>Second list Item3</BulletListItem>
      <BulletListItem>Second list Item4</BulletListItem>
      <Body>Redacted</Body>
    </Section>
  </Story>
</Root>
Run Code Online (Sandbox Code Playgroud)

有了这个XSL:

<xsl:stylesheet version="1.0" …
Run Code Online (Sandbox Code Playgroud)

xml xslt

8
推荐指数
2
解决办法
3206
查看次数

使用def函数时无法在Python中打印变量

我正在尝试实现一个简单的神经网络.我想打印初始图案,重量,激活.然后我想要它打印学习过程(即它学习时经历的每个模式).我还是无法做到这一点 - 它返回了初始和最终模式(我将print p放在适当的位置),但没有别的.提示和提示赞赏 - 我是Python的新手!

#!/usr/bin/python
import random

p = [ [1, 1, 1, 1, 1],
      [1, 1, 1, 1, 1],
      [0, 0, 0, 0, 0],
      [1, 1, 1, 1, 1],
      [1, 1, 1, 1, 1] ] # pattern I want the net to learn
n = 5
alpha = 0.01
activation = []   # unit activations
weights = []      # weights
output = []       # output



def initWeights(n):  # set weights to zero, n is the number of …
Run Code Online (Sandbox Code Playgroud)

python

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

在您的项目根目录中为中高规模站点提供十几个django应用程序是否典型?它不觉得臃肿吗?

我在看django-mingus的INSTALLED_APPS:

INSTALLED_APPS = (
  'django.contrib.auth',
  'django.contrib.contenttypes',
  'django.contrib.sessions',
  'django.contrib.sites',
  'django.contrib.admin',
  'django.contrib.sitemaps',
  'django.contrib.flatpages',
  'django.contrib.redirects',

  'django_extensions',
  'tagging',
  'djangodblog',
  'disqus',
  'basic.inlines',
  'basic.blog',
  'basic.bookmarks',
  'basic.media',
  'oembed',
  'flatblocks',
  'dbtemplates',
  'navbar',
  'sorl.thumbnail',
  'template_utils',
  'django_proxy',

  'django_markup',
  'google_analytics',
  'robots',
  'basic.elsewhere',
  'compressor',
  'contact_form',
  'honeypot',
  'sugar',
  'quoteme',
  'mingus.core',
  'debug_toolbar',

  'django_twitter',
  'django_bitly',
  'staticfiles',
  'tinymce',
  'django_wysiwyg',
  'cropper',
  'memcache_status',
  'request',
)
Run Code Online (Sandbox Code Playgroud)

这确实有些臃肿.但我认为这真的没有它看起来那么糟糕,因为django只使用所请求的内容,因为它不会为每个请求加载每个应用程序,但只有在它被调用时?如果没有,有人可以揭开这个过程的神秘面纱吗?

python django

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

如何从网上显示图像?

我在python中编写了这个简单的脚本:

import gtk

window = gtk.Window()
window.set_size_request(800, 700)

window.show()
gtk.main()
Run Code Online (Sandbox Code Playgroud)

现在我想在这个窗口中加载来自web(而不是我的PC)的图像,如下所示:

http://www.dailygalaxy.com/photos/uncategorized/2007/05/05/planet_x.jpg

我怎样才能做到这一点 ?

PS我不想下载图像!我只想从URL加载图像.

python gtk pygtk

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

在(Qt)应用程序中集成广告的解决方案

我正在开发一个软件,我想免费提供应用程序内的广告横幅.像Spotify中的横幅或MS Live Messenger联系人列表中的横幅.类似于在iOS应用程序中集成的iAd系统.

这有什么解决方案吗?我正在编写一个多平台C++ Qt应用程序.当然,我可以使用网络浏览器框架并使用基于网络的广告系统,但这对于用户来说非常容易阻止.因此,我更喜欢一种也可以某种方式离线工作的系统.

c++ qt ads

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

将Eclipse的"Open Call Hierarchy"过滤到我的公司/项目

我最喜欢的Eclipse功能之一是能够打开方法的调用者/被调用者层次结构.

默认情况下,该视图显示对我/我的代码库之外的类的调用...我通常不关心.

有过滤的选项,我不想具体的包名,但我需要做相反的事情......过滤所有包,除了一个我想要的.这里使用什么适当的正则表达式"匹配所有字符串,除了那些以com.mycompany.?开头的字符串?"

替代文字

regex language-agnostic eclipse call-hierarchy

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

在一个页面中执行此PHP + MYSQL的更好方法是什么?

我的方法:

<?

switch($id) 
{ 
    case 1:
?>
        a lots of html stuff goes here...
<?    
    break;  
    case 2:
?>
        a lots of html stuff goes here2...
<?    
    break;        
}

?>
Run Code Online (Sandbox Code Playgroud)

有什么方法可以做这个漂亮的东西吗?我的意思是更具可读性或什么?我真的应该这样做.(还没学会聪明......)

html php coding-style

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

获取锁失败的线程会发生什么?

无法获取锁(非自旋)的线程会发生什么?它进入 BLOCKED 状态。它如何再次执行?

Lock lck = new ReentrantLock();
lck.lock()
try
{
}
finally
{
   lck.unlock();
}
Run Code Online (Sandbox Code Playgroud)

java locking monitor blocking

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

"MyType"问题:我是否必须在Scala中使用抽象类型(或泛型)来返回实际的类?

我不确定是否有更好的方法:

trait Animal {
  val name: String
  val weight: Int

  type SubAnimal <: Animal

  def updateName(n: String) = returnMe(n, this.weight)
  def updateWeight(w: Int) = returnMe(this.name, w)
  // Abstract protected method
  protected def returnMe(n: String, w: Int): SubAnimal
}

case class Dog(name: String, weight: Int) extends Animal {
  type SubAnimal = Dog
  override def returnMe(n: String, w: Int): Dog = Dog("Dog: " + name, w)
}
case class Cat(name: String, weight: Int) extends Animal {
  type SubAnimal = Cat
  override def …
Run Code Online (Sandbox Code Playgroud)

generics scala

9
推荐指数
3
解决办法
838
查看次数