我坚持使用此代码为无限循环创建unittest.
try:
while True:
time.sleep(60)
except:
fun()
Run Code Online (Sandbox Code Playgroud)
请告诉我们如何创建无限循环的单元测试?
我正在研究python,我坚持这个问题.
输入(有一个元组):
a = (0, 1)
Run Code Online (Sandbox Code Playgroud)
输出:
a = 0.1
Run Code Online (Sandbox Code Playgroud) 我正在研究流式细胞仪.我想使用python解析.fcs文件.我在互联网上研究过,有一个模块,fcm但是对于linux操作系统,我正在开发Windows.
我想知道如何使用python在Windows中解析.fcs文件?
如果有人知道如何fcm在Windows中使用,请让我知道.
我开始研究beautifulsoup来解析HTML.
例如,对于网站" http://en.wikipedia.org/wiki/PLCB1 "
import sys
sys.setrecursionlimit(10000)
import urllib2, sys
from BeautifulSoup import BeautifulSoup
site= "http://en.wikipedia.org/wiki/PLCB1"
hdr = {'User-Agent': 'Mozilla/5.0'}
req = urllib2.Request(site,headers=hdr)
page = urllib2.urlopen(req)
soup = BeautifulSoup(page)
table = soup.find('table', {'class':'infobox'})
#print table
rows = table.findAll("th")
for x in rows:
print "x - ", x.string
Run Code Online (Sandbox Code Playgroud)
在某些有url的情况下,我输出为None.为什么会这样?
输出:
x - Phospholipase C, beta 1 (phosphoinositide-specific)
x - Identifiers
x - None
x - External IDs
x - None
x - None
x - Molecular function
x - Cellular component …Run Code Online (Sandbox Code Playgroud) 我有两个清单:
a = ['1', '2']
b = ['11', '22', '33', '44']
Run Code Online (Sandbox Code Playgroud)
我将它们组合起来创建一个如下所示的列表:
op = [('1', '11'), ('2', '22'), ('', '33'), ('', '44')]
Run Code Online (Sandbox Code Playgroud)
我怎么能实现这个目标?
我想使用lxml从html页面中找出所有url及其名称.
我可以解析网址,可以找到这个东西,但有没有简单的方法,我可以找到使用lxml的所有网址链接?
我正在研究.smiles文件..smiles文件的文件结构是:http://en.wikipedia.org/wiki/Chemical_file_format#SMILES
我想从微笑文件中获取所有原子.这意味着如果存在单个"C"原子,则意味着将有4个"H"原子连接到它们.
我在搜索时发现python中有一些模块可以解析微笑格式,但它们不会给出支持的氢原子.(例如:它们只给'C'而不是其他4'H'原子连接到'C'原子)
如何使用python找到所有原子,包括连接的'H'原子.
需要转换为包含连接的'H'原子的所有原子的smiles文件示例:
[H]OC([H])([H])[C@@]1([H])C([H])=C([H])[C@@]([H])(n2c([H])nc3c(nc(nc23)N([H])[H])N([H])C2([H])C([H])([H])C2([H])[H])C1([H])[H]
Run Code Online (Sandbox Code Playgroud)
先感谢您.
我正在使用numpy的多维列表
我有一份清单.
l = [[0 2 8] [0 2 7] [0 2 5] [2 4 5] [ 8 4 7]]
Run Code Online (Sandbox Code Playgroud)
我需要找到平方列之和的平方根.
0 2 8
0 2 7
0 2 5
2 4 5
8 4 7
Run Code Online (Sandbox Code Playgroud)
输出为,
l = [sqrt((square(0) + square(0) + square(0) + square(2) + square(8)) sqrt((square(2) + square(2) + square(2) + square(4) + square(4)) sqrt((square(8) + square(7) + square(5)) + square(5) + square(7))]
Run Code Online (Sandbox Code Playgroud) 我有一个简单的python函数。
def test():
print "test"
sys.exit(1)
Run Code Online (Sandbox Code Playgroud)
我正在使用 python 2.6。如何为此功能创建单元测试?这是因为 sys.exit 可以在 python 2.7 之后的单元测试用例中处理。
谁能让我知道如何为这个简单的代码创建单元测试?
I have a python dictionary.
a = {'1':'saturn', '2':'venus', '3':'mars', '4':'jupiter', '5':'rahu', '6':'ketu'}
planet = input('Enter planet : ')
print(planet)
Run Code Online (Sandbox Code Playgroud)
If user enteres 'rahu', dictionary to be sorted like the following
a = {'1':'rahu', '2':'ketu', '3':'saturn', '4':'venus', '5':'mars', '6':'jupiter' }
print('4th entry is : ')
Run Code Online (Sandbox Code Playgroud)
它应该根据字典中的下一个值对字典进行排序。如果字典结束,则应从字典的初始值开始。它应该打印字典的第四个条目,它应该返回
venus
Run Code Online (Sandbox Code Playgroud)
如何根据用户输入值对python字典进行排序?
python ×10
unit-testing ×2
biopython ×1
dictionary ×1
file ×1
html ×1
list ×1
lxml ×1
numpy ×1
python-3.x ×1
tuples ×1