我试图在即将到来的项目中使用线程,但我无法让它工作.我试过在http://www.tutorialspoint.com/python/python_multithreading.htm上运行第二个例子,我想这是工作代码,但是我得到了错误...
Traceback (most recent call last):
File "C:/Python27/threads/threading.py", line 3, in <module>
import threading2
File "C:\Python27\lib\site-packages\threading2\__init__.py", line 49, in <module>
from threading import _active,_DummyThread
File "C:\Python27\threads\threading.py", line 8, in <module>
class myThread (threading2.Thread):
AttributeError: 'module' object has no attribute 'Thread'
Run Code Online (Sandbox Code Playgroud)
这是怎么回事?似乎没有名为threading的模块.我到处寻找它.有谁知道我在哪里可以找到这个模块以及如何安装它?
我正在尝试使用以下代码行从HTML中提取parapgraph:
paragraphs = re.match(r'<p>.{1,}</p>', html)
Run Code Online (Sandbox Code Playgroud)
但即使我知道有,也没有返回.为什么?
我需要在python中使用正则表达式来获取{}中的所有单词
a = 'add {new} sentence {with} this word'
Run Code Online (Sandbox Code Playgroud)
re.findall的结果应该是[new,with]
谢谢
我想将python代码转换为java.但我不明白切片步骤参数.
例:
x = "Hello World !"
x[6:2:-1]
Run Code Online (Sandbox Code Playgroud)
x [6:2:-1]的结果是什么?
我需要遍历列表并检查值是字符串还是int.有没有简单的方法在python中执行此操作?
例如:
[1,2,3] 是真的.
["a",2,3] 会是假的.
说我有一个文本字符串
"StringText someText Wwwwww SomeOtherText OtherText SOMETextMore etc etc etc"
Run Code Online (Sandbox Code Playgroud)
并且需要小写从"S"或"s"开始的所有单词.但不是别的话.请使用重新代码(更好地使用re,而不是普通循环来替换字符,请参阅).Py2x.
python ×6
regex ×3
python-2.7 ×2
string ×2
html ×1
html-parsing ×1
installation ×1
list ×1
slice ×1