尝试对某些文件批量运行正则表达式。
正则表达式代码:
import re
def DOCtoSTRING(path):
return text
def valuesHextractor(text):
STRING =""
#let's find pacient personal info
regex = re.compile('CONSULTA?IE(?s).*EXAMENUL')
pacientdata=regex.search(text)
pacientinfo = re.sub('[A-Z]+:',"",pacientdata[0])
STRING=STRING+pacientinfo.strip("CONSULTA?IE").strip("EXAMENUL")+" "
#values
regex = re.compile('EXAMENUL OFTALMOLOGIC:(?s).*TRATAMENT')
pacientvalues=regex.search(text)
#AV OD
#fc
regex=re.compile("1.AV.*OD.*?fc[;\.\+\- 0-9]*")
AVfc=regex.search(pacientvalues[0])
AVODfc=re.sub("1.AV.*OD.*?fc[;\. 0-9]*?","",AVfc[0])
regex=re.compile("[\+\-0-9]+")
if regex.search(AVODfc)==None:
AVODfc="None"
STRING=STRING+AVODfc+" "
#cc
regex=re.compile("1.AV.*OD.*?cc[;\.\+\- 0-9]*")
AVcc=regex.search(pacientvalues[0])
AVODcc=re.sub("1.AV.*OD.*?cc[;\. 0-9]*?","",AVcc[0])
regex=re.compile("[\+\-0-9]+")
if regex.search(AVODcc)==None:
AVODcc="None"
STRING=STRING+AVODcc+" "
#cyl
regex=re.compile("1.AV.*OD.*?cyl[;\.\+\- 0-9]*")
AVcyl=regex.search(pacientvalues[0])
AVODcyl=re.sub("1.AV.*OD.*?cyl[;\. 0-9]*?","",AVcyl[0])
regex=re.compile("[\+\-0-9]+")
if regex.search(AVODcyl)==None:
AVODcyl="None"
STRING=STRING+AVODcyl+" "
#ax
regex=re.compile("1.AV.*OD.*?ax[;\.\+\- 0-9]*")
AVax=regex.search(pacientvalues[0])
AVODax=re.sub("1.AV.*OD.*?ax[;\. 0-9]*?","",AVax[0])
regex=re.compile("[\+\-0-9]+")
if regex.search(AVODax)==None:
AVODax="None" …Run Code Online (Sandbox Code Playgroud) 我找到了各种关于如何使TWebBrowser使用代理的例子(如202.8.128.5:8080).但是,所有这些示例都是为所有正在运行的TWebBrowser实例全局更改代理.我有两个例子.如何为每个浏览器设置不同的代理?
我已经使用名为的按钮设置了我创建的delphi应用程序Connect.单击它后,它将执行以下代码:
begin
someConnection.Connected:=true;
somecomenziDataSet.Active:=true;
end;
Run Code Online (Sandbox Code Playgroud)
同样地,我有一个按钮用于Disconnect做同样的事情,但是= false;
我的问题是我连接的数据库托管在共享主机帐户上,而mysql服务器的wait_timeout变量设置为60秒,interactive_timeout设置为30秒.当然,如果我不使用我的应用程序60秒,这将断开我.
有没有办法让这个连接保持活力?
托管公司不会改变设置,所以我坚持使用它.
我正在使用RAD Studio 10 Seattle,dbexpress组件TSQLConnection和我的数据库mysql
如果我留下任何必要的信息,请在评论中告诉我,谢谢!
我将新的订单详细信息添加到我的数据库中的表中.其中一个列email是以我创建的形式命名的,用于在我的delphi应用程序中添加新订单,随后在db中,我使用TEdits来传递数据.
这是代码:
procedure TForm2.actAddComandaExecute(Sender: TObject);
begin
if dbmodule.comenziConnection.Connected then
begin
if addOrderForm.ShowModal=mrok then
begin
dbmodule.comenziQuery.SQL.Clear;
dbmodule.comenziQuery.SQL.Add( 'insert into `r33758pi_tipotask`.`comenzi` ( stare, client, telefon, email, detalii, livrare, pret, user, status, observatii ) values ( :stare, :client, :telefon, :email, :detalii, :livrare, :pret, :user, :status, :observatii ) ' ) ;
dbmodule.comenziQuery.Params.ParamByName( 'stare' ).AsString := addOrderForm.ComboBoxEx1.Text ;
dbmodule.comenziQuery.Params.ParamByName( 'client' ).AsString := addOrderForm.Edit2.Text ;
dbmodule.comenziQuery.Params.ParamByName( 'telefon' ).AsString := addOrderForm.Edit3.Text ;
dbmodule.comenziQuery.Params.ParamByName( 'email' ).AsString := addOrderForm.Edit4.Text ;
dbmodule.comenziQuery.Params.ParamByName( 'detalii' ).AsString := addOrderForm.Edit5.Text …Run Code Online (Sandbox Code Playgroud) 我在做什么:
FileUpload组件(对话框)将启动,他可以从他的PC浏览并加载文件.因此,无论文件在用户加载时的名称如何,它都会以他的Firstname和来保存到磁盘中LastName,这是我从一些字符串变量中获得的.
UniMainModule.foldername =包含保存文件的文件夹的路径.
UniMainModule.FirstName =包含用户的FirstName
UniMainModule.LastName =包含用户的LastName
因此,文件将保存FirstName_LastName.pdf在磁盘上由foldername字符串提供的位置.
这是我正在使用的代码:
procedure TsomeForm.UniFileUpload1Completed(Sender: TObject; AStream: TFileStream);
var
DestName : string;
DestFolder : string;
begin
DestFolder:=UniServerModule.StartPath+'files\'+UniMainModule.foldername+'\';
DestName:=DestFolder+UniMainModule.FirstName+'_'+UniMainModule.LastName+'.pdf';
CopyFile(PChar(AStream.FileName), PChar(DestName), False);
ModalResult:= mrOk;
end;
Run Code Online (Sandbox Code Playgroud)
据我了解,阅读一些关于后CopyFile上msdn通过False,这意味着应该,将覆盖现有文件.
如果该文件在该位置尚未出现该名称,则可以保存.
但是,如果用户决定再次使用fileupload并上传新文件,则新文件将覆盖前一个文件.因为他们被保存为同名.
那么如何确保如果文件已经存在(位置中存在具有该确切名称的文件),它不会被覆盖,但是,我不知道,在名称或其他内容中被分配了(1),保留两个文件?
delphi ×4
mysql ×2
sql ×2
dbexpress ×1
delphi-xe7 ×1
file-copying ×1
python ×1
python-3.x ×1
twebbrowser ×1