s = r'abc123d, hello 3.1415926, this is my book'
print re.findall(r'-?[0-9]+(?:\.[0-9]*)?|-?\.[0-9]+',s)
Вам не нужно escape
дважды, когда вы используете raw mode
.
Выход: ['123', '3.1415926']
Также тип возврата будет списком strings
.Если вы хотите, чтобы возвращаемый тип, как integers
и floats
, использовал map
import re,ast
s = r'abc123d, hello 3.1415926, this is my book'
print map(ast.literal_eval,re.findall(r'-?[0-9]+(?:\.[0-9]*)?|-?\.[0-9]+',s))
Выход: [123, 3.1415926]
у меня нет проблем с
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.3.1.GA</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>3.4.0.GA</version>
</dependency>
и
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.5.6</version>
</dependency>
<!-- concrete Log4J Implementation for SLF4J API-->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.5.6</version>
</dependency>
После проверки АНГЛИЧАНИНА версии 1.5.6 для slf4j-log4j (и затем slf4j-порождают) необходимо использовать log4j-1.2.14. slf4j-log4j АНГЛИЧАНИН использует управление зависимостью для наследования соответствующей версии log4j от slf4j-родительского АНГЛИЧАНИНА.
Вы не должны, однако, должны быть включать log4j как определенную зависимость, поскольку это уже - зависимость slf4j-log4j. Это, возможно, было то, где Вы вызвали свою проблему.
Поиск Google нашел это:
http://marc.info/?l=slf4j-user&m=122218775201271&w=2
, Возможно, необходимо проверить версии JAR, чтобы удостовериться, что они совместимы.
На этот вопрос отвечает FAQ по SLF4J. Пожалуйста, смотрите
http://slf4j.org/faq.html#compatibility и http://slf4j.org/faq.html#IllegalAccessError
I think you need to exclude the built-in SLF4J dependency from each of the Hibernate dependencies.
I use Hibernate with JPA, so my config isn't identical, but I think the crucial thing is to explicitly include log4j and SLF4J and explicitly exclude slf4j-api from all org.hibernate dependencies:
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.15</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>com.sun.jmx</groupId>
<artifactId>jmxri</artifactId>
</exclusion>
<exclusion>
<groupId>javax.jms</groupId>
<artifactId>jms</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jdmk</groupId>
<artifactId>jmxtools</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>3.4.0.GA</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>3.4.0.GA</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.5.6</version>
<scope>runtime</scope>
</dependency>