我想在variable里面用一个regex,我怎么能这样做Python呢?
TEXTO = sys.argv[1]
if re.search(r"\b(?=\w)TEXTO\b(?!\w)", subject, re.IGNORECASE):
# Successful match
else:
# Match attempt failed
Run Code Online (Sandbox Code Playgroud) 我正在尝试制作一个使用Android 新蓝牙低功耗API的应用程序.为此,我开始使用API等级为18的BLE样本.
当我读到Android无法充当外围设备时,我将Android手机置于中央模式,扫描周围的BLE设备.为此,我使用模拟心脏传感器的北欧平台进行了一些测试.一切都以完美的方式运作!
在此之后,我尝试选择iPhone(iOS 7 beta 4)并将其置于外围设备中并模拟心率传感器作为之前的测试.Android应用程序可以看到设备并连接到它.但是在连接激活后,2个设备会在3-4秒内断开连接.除此之外,当我在Android端调用discoverServices()时,不会触发回调!在某些情况下,即使iOS蓝牙芯片处于关闭状态,Android设备也会收到"已连接"事件.这很奇怪.为了证明这一点,我将Nordic Board置于中央模式,并且我能够正确连接到iOS设备,没有任何问题.
会是什么呢?Android或iOS有一些限制,不允许从Android连接到iOS或反之亦然?
谢谢.
编辑:经过一些艰难的测试,我在AOSP页面上提出了一个问题.可以在这里查看
android ios core-bluetooth bluetooth-lowenergy android-4.3-jelly-bean
我使用Pycharm 2016.1的CentOS7,我测试" Show command line afterwards",我得到了这个问题:
AttributeError: 'PyDevTerminalInteractiveShell' object has no attribute 'has_readline'
Run Code Online (Sandbox Code Playgroud)
/usr/bin/python3.4 /usr/local/pycharm/helpers/pydev/pydev_run_in_console.py 37196 52554 /root/PycharmProjects/mytf/mytest/test5.py
Traceback (most recent call last):
File "/usr/local/pycharm/helpers/pydev/pydev_run_in_console.py", line 63, in <module>
interpreter = InterpreterInterface(host, int(client_port), threading.currentThread())
File "/usr/local/pycharm/helpers/pydev/_pydev_bundle/pydev_ipython_console.py", line 26, in __init__
self.interpreter = get_pydev_frontend(host, client_port, show_banner=show_banner)
File "/usr/local/pycharm/helpers/pydev/_pydev_bundle/pydev_ipython_console_011.py", line 473, in get_pydev_frontend
_PyDevFrontEndContainer._instance = _PyDevFrontEnd(show_banner=show_banner)
File "/usr/local/pycharm/helpers/pydev/_pydev_bundle/pydev_ipython_console_011.py", line 303, in __init__
self.ipython = PyDevTerminalInteractiveShell.instance()
File "/usr/lib/python3.4/site-packages/traitlets/config/configurable.py", line 412, in instance
inst = cls(*args, **kwargs)
File "/usr/lib/python3.4/site-packages/IPython/terminal/interactiveshell.py", …Run Code Online (Sandbox Code Playgroud) 我正在开发一个带有的Android应用程序webView.在某些urls我需要使用这个shouldOverrideUrlLoading方法,这是非常直接的:
if(url.startsWith("something")){
//do something
return true;
}
Run Code Online (Sandbox Code Playgroud)
我的问题:
URLS例如,谷歌搜索中的一些有以下URL方案:
intent://en.m.wikipedia.org/wiki/Test_cricket#Intent;scheme=http;package=org.wikipedia;S.browser_fallback_url=https%3A%2F%2Fwww.google.pt%2Fsearchurl%2Fr.html%23app%3Dorg.wikipedia%26pingbase%3Dhttps%3A%2F%2Fwww.google.pt%2F%26url%3Dhttps%3A%2F%2Fen.m.wikipedia.org%2Fwiki%2FTest_cricket;S.android.intent.extra.REFERRER_NAME=https%3A%2F%2Fwww.google.pt;launchFlags=0x8080000;end
Run Code Online (Sandbox Code Playgroud)
我尝试过使用:
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(browserIntent);
Run Code Online (Sandbox Code Playgroud)
但是我收到了一个错误:
10-15 15:18:15.546: W/System.err(29086): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=intent://en.m.wikipedia.org/wiki/Test_cricket }
Run Code Online (Sandbox Code Playgroud)
我该如何处理这种URL方案?
更新:
在@CommonsWare评论之后,我尝试使用parseUri()on Intent来创建一个Intent objectfrom URL然后尝试startActivity(),例如:
Intent myIntent = new Intent().parseUri(url, Intent.URI_INTENT_SCHEME);
startActivity(myIntent);
Run Code Online (Sandbox Code Playgroud)
但我仍然得到:
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=http://en.m.wikipedia.org/wiki/Test_cricket flg=0x8080000 pkg=org.wikipedia (has extras) …Run Code Online (Sandbox Code Playgroud) 我正在使用熊猫来分析一些选举结果.我有一个DF,结果,每个选区都有一行,代表各方投票的列(超过100个):
In[60]: Results.columns
Out[60]:
Index(['Constituency', 'Region', 'Country', 'ID', 'Type', 'Electorate',
'Total', 'Unnamed: 9', '30-50', 'Above',
...
'WP', 'WRP', 'WVPTFP', 'Yorks', 'Young', 'Zeb', 'Party', 'Votes',
'Share', 'Turnout'],
dtype='object', length=147)
Run Code Online (Sandbox Code Playgroud)
所以...
In[63]: Results.head()
Out[63]:
Constituency Region Country ID Type \
PAID
1 Aberavon Wales Wales W07000049 County
2 Aberconwy Wales Wales W07000058 County
3 Aberdeen North Scotland Scotland S14000001 Burgh
4 Aberdeen South Scotland Scotland S14000002 Burgh
5 Aberdeenshire West & Kincardine Scotland Scotland S14000058 County
Electorate Total Unnamed: 9 30-50 Above …Run Code Online (Sandbox Code Playgroud) 在android repo的哪个文件中我必须更改默认的用户代理?我需要将此字符串设置为媒体播放器的默认用户代理: HTC Streaming Player vodafone_uk/1.0/htc_bravo/2.2
我已经根据http://en.wikipedia.org/wiki/Vehicle_identification_number编写了一个VIN验证RegEx,但是当我尝试运行一些测试时,它不接受一些有效的VIN编号.
我的RegEx:
^[A-HJ-NPR-Za-hj-npr-z\\d]{8}[\\dX][A-HJ-NPR-Za-hj-npr-z\\d]{2}\\d{6}$
Run Code Online (Sandbox Code Playgroud)
VIN号不工作:
1ftfw1et4bfc45903
WP0ZZZ99ZTS392124
VIN号码工作:
19uya31581l000000
1hwa31aa5ae006086
(我认为问题出现在最后的数字,维基百科听起来像它只会以6个数字结束而一个不起作用但是有效数字只以5结尾)
任何帮助纠正这个问题将不胜感激!
如何$pw在单引号内扩展?
$pw = "$PsHome\powershell.exe"
cmd.exe /c 'schtasks /create /tn cleanup /tr "$pw -WindowStyle hidden -ExecutionPolicy Bypass -nologo -noprofile %TEMP%\exec.ps1" /sc minute /mo 1'
Run Code Online (Sandbox Code Playgroud) 我试图排除所有以"dgg-"开头并以".xml" 结尾的文件,例如:dgg-file-1.xml使用apache代理.
这有效:
ProxyPass /myfile.xml ! # single file
ProxyPass /directory ! # all files inside dir
Run Code Online (Sandbox Code Playgroud)
这不起作用:
ProxyPass /dgg-(.*)\.xml !
我怎样才能做到这一点?
PS-我用这里面的代码httpd.conf->virtualhost 不会 .htaccess.
从昨晚开始,我的几个使用file_get_contents("https://...")和curl运行的脚本(在不同的服务器上)停止工作。
失败的请求示例:
file_get_contents("https://domain.tld/script.php");
Run Code Online (Sandbox Code Playgroud)
错误:
PHP Warning: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages:
error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed in /home/domain/public_html/script.php on line 19
Run Code Online (Sandbox Code Playgroud)
我已经使用以下方法“修复”了该问题:
$arrContextOptions=array(
"ssl"=>array(
"verify_peer"=>false,
"verify_peer_name"=>false,
),
);
file_get_contents("https://domain.tld/path/script.php", false, stream_context_create($arrContextOptions));
Run Code Online (Sandbox Code Playgroud)
“修复”远非理想,因为我没有验证连接的真实性,但在我了解问题的根源以及如何防止它再次发生之前,我将被迫使用它。
注意事项:
Curl也停止工作,修复方法类似:
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);;SSL由昨晚颁发Let's Encrypt并更新(“ 2020/12/24 之前无效”);CentOS 7/Ubuntu 18和Virtualmin;"https://domain.tld/script.php"在 Firefox/Chrome 上打开,则不会显示 SSL 警告,并且证书有效; …android ×3
python ×3
regex ×3
apache ×1
curl ×1
dataframe ×1
escaping ×1
ios ×1
media-player ×1
mod-rewrite ×1
numpy ×1
pandas ×1
php ×1
powershell ×1
proxypass ×1
pycharm ×1
python-3.x ×1
ssl ×1
user-agent ×1
validation ×1
variables ×1
virtualmin ×1
webview ×1