如果我有一些xml包含以下mediawiki标记:
"...收集于12世纪,其中[[亚历山大大帝]]是英雄,并且代表他,有点像英国[[亚瑟王|亚瑟]]"
什么是适当的论据,如:
re.findall([[__?__]], article_entry)
我有点躲过双方括号,并得到文本的正确链接,如: [[Alexander of Paris|poet named Alexander]]
我希望能够在一个帧中显示Notebook和TxtCtrlwx小部件.下面是一个改编自wxpython wiki的例子; 是否有可能改变他们的布局(可能有类似的东西wx.SplitterWindow)来显示Notebook同一帧下面的文本框?
import wx
import wx.lib.sheet as sheet
class MySheet(sheet.CSheet):
def __init__(self, parent):
sheet.CSheet.__init__(self, parent)
self.SetLabelBackgroundColour('#CCFF66')
self.SetNumberRows(50)
self.SetNumberCols(50)
class Notebook(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title, size=(600, 600))
menubar = wx.MenuBar()
file = wx.Menu()
file.Append(101, 'Quit', '' )
menubar.Append(file, "&File")
self.SetMenuBar(menubar)
wx.EVT_MENU(self, 101, self.OnQuit)
nb = wx.Notebook(self, -1, style=wx.NB_BOTTOM)
self.sheet1 = MySheet(nb)
self.sheet2 = MySheet(nb)
self.sheet3 = MySheet(nb)
nb.AddPage(self.sheet1, "Sheet1")
nb.AddPage(self.sheet2, "Sheet2")
nb.AddPage(self.sheet3, "Sheet3")
self.sheet1.SetFocus()
self.StatusBar()
def StatusBar(self): …Run Code Online (Sandbox Code Playgroud) 我正在寻找一个正则表达式来检查http表单中的有效SI单位输入.所以,例如,
kg/m^3
对密度有效
m/s^2
加速.
这似乎是一些开放式图书馆可能已经解决的问题; 或者从一组有限的基本单位开始,可能有一种聪明的方法.它适用于要求用户遵循特定输入规则的学术环境.
我在一个有用的Bash脚本中有这一行,我没有设法将其转换为Python,其中'a'是用户输入的存档天数值:
find ~/podcasts/current -mindepth 2 -mtime '+`a`+' -exec mv {} ~/podcasts/old \;
Run Code Online (Sandbox Code Playgroud)
我熟悉最常用的跨平台元素的os.name和getpass.getuser.我也有这个函数来生成相当于〜/ podcasts/current的所有文件的全名列表:
def AllFiles(filepath, depth=1, flist=[]):
fpath=os.walk(filepath)
fpath=[item for item in fpath]
while depth < len(fpath):
for item in fpath[depth][-1]:
flist.append(fpath[depth][0]+os.sep+item)
depth+=1
return flist
Run Code Online (Sandbox Code Playgroud)
首先,必须有更好的方法,任何建议欢迎.无论哪种方式,例如,"AllFiles('/ users/me/music/itunes/itunes music/podcasts')"在Windows上提供相关列表.据推测,我应该能够查看此列表并调用os.stat(list_member).st_mtime并将所有超过特定数字的内容移动到存档中; 我有点卡在那一点上.
当然,任何具有bash命令简洁性的东西也会很有启发性.
我正在从Python词典构建一些Postgres表,其中{'key':'value'}对对应于列'key'和字段'value'.这些是从.dbf文件生成的 - 我现在将.dbf文件的内容传递给一个脚本,该脚本返回一个dicts列表,如:
{'Warngentyp': '', 'Lon': '-81.67170', 'Zwatch_war': '0', 'State':...
Run Code Online (Sandbox Code Playgroud)
目前我将这些放入没有类型声明的sqlite数据库,然后将其转储到.sql文件,手动编辑架构,并导入Postgres.
我希望能够推断出正确的类型声明,基本上遍历一个字符串列表,如['0','3','5']或['ga','ca','tn']或[ '-81.009','135.444',' - 80.000']并生成类似'int','varchar(2)','float'的内容.(我会对Python,Postgres或SQLite工具同样满意.)
有没有这样做的包,或者直接实现它的方法?