小编use*_*290的帖子

Python - 检查字符串中的最后一个字符是否为数字

基本上我想知道我会怎么做.

这是一个示例字符串:

string = "hello123"
Run Code Online (Sandbox Code Playgroud)

我想知道如何检查字符串是否以数字结尾,然后打印字符串结尾的数字.

我知道对于这个特定的字符串,您可以使用正则表达式来确定它是否以数字结尾,然后使用字符串[:]来选择"123".但是,如果我循环使用这样的字符串文件:

hello123
hello12324
hello12435436346
Run Code Online (Sandbox Code Playgroud)

...然后由于数字长度的不同,我将无法使用字符串[:]来选择数字.我希望我能够清楚地解释我需要什么来帮助你们.谢谢!

python regex string numbers

34
推荐指数
3
解决办法
4万
查看次数

在iTunes和Chrome中,Twitter Typeahead和bootstrap-tags输入样式不正确

摘要

我最近一直在为我的网站开发一个消息系统,它包含Twitter Typeahead插件和bootstrap-tagsinput插件.但是当我在Internet Explorer和谷歌浏览器中加载我的页面时,我的css存在样式问题,而它在firefox中运行正常(可能是因为我用它进行开发和初始样式编辑).我想知道如何解决这个问题,因为我对css不是很有经验,这就是为什么Iv'e试图让这个问题尽可能简单.

请阅读下面的问题.


在Firefox中工作(开发)

下面是我的输入框在firefox中正常工作的图像: 在此输入图像描述

在此输入图像描述


Internet Explorer样式问题(编辑:已修复!)

  1. 在添加标签之前,输入框未与glyphicon对齐. 在此输入图像描述
  2. 输入文本未与左侧的标签对齐. 在此输入图像描述
  3. 占位符字体颜色和样式与表单的其余部分不对应. 在此输入图像描述

Google Chrome样式问题(编辑:已修复)

Typeahead下拉列表未正确对齐.(仅在第一个标签上出现,否则可以正常工作). 在此输入图像描述


我的HTML:

<span id="remote" class="input-group" style="padding-bottom:10px;">
  <span class="input-group-addon"><span class="glyphicon glyphicon-user" style="font-size: 15px;"></span></span>
  <input type="text" autocomplete="off" name="msgUser" id="msgUser" class="form-control tagsInput" placeholder="Users Seperated by ,"/>
</span>
Run Code Online (Sandbox Code Playgroud)

Typeahead CSS:

.accordion {
    margin-bottom:-3px;
}

.accordion-group { 
    border: none;
}

.twitter-typeahead .tt-query,
.twitter-typeahead .tt-hint {
  margin-bottom: 0;
}

.twitter-typeahead .tt-hint
{
    display: none;
}

.tt-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 1000;
  display: none;
  float: left;
  min-width: 160px; …
Run Code Online (Sandbox Code Playgroud)

html css jquery twitter-bootstrap

12
推荐指数
1
解决办法
1183
查看次数

Python - 不要只关注一个URL上的重定向

我想知道如何阻止urllib2跟随我选择的网址上的重定向请求.我在浏览时发现了这段代码,但它似乎全局工作,我只希望它禁用某个网址上的重定向:

import urllib2
class RedirectHandler(urllib2.HTTPRedirectHandler):
    def http_error_302(self, req, fp, code, msg, headers):
        result = urllib2.HTTPError(req.get_full_url(), code, msg, headers, fp)
        result.status = code
        return result
    http_error_301 = http_error_303 = http_error_307 = http_error_302

opener = urllib2.build_opener(RedirectHandler())
webpage = opener.open('http://www.website.com').geturl()
print webpage
Run Code Online (Sandbox Code Playgroud)

我还应该提一下,我正在使用urllib.urlopen('site.com')请求网址,我希望第一次重定向允许发生,例如说site.com重定向到site.com/redirect但是它尝试再次从site.com/redirect重定向到site.com/secondredirect我希望脚本能够识别网址中的"secondredirect"并停止发生该请求.我希望我能很好地解释这一切并希望看到一些回复,因为我花了几个小时试图解决这个问题:头痛:

python redirect urllib2

3
推荐指数
2
解决办法
5414
查看次数

标签 统计

python ×2

css ×1

html ×1

jquery ×1

numbers ×1

redirect ×1

regex ×1

string ×1

twitter-bootstrap ×1

urllib2 ×1