假设我有以下字符串
str = 'http://www.example.com/servlet/av/jd?ai=782&ji=2553120&sn=I'
Run Code Online (Sandbox Code Playgroud)
我想只得到整数ji,255312因为ji在上面的网址中可能会有不同的数字生成
提前致谢......
嗨,我想从这里安装pycrypto-2.3
我下载并运行以下命令
cd pycrypto-2.3/
python setup.py install
Run Code Online (Sandbox Code Playgroud)
我收到以下错误,
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/Crypto
copying lib/Crypto/pct_warnings.py -> build/lib.linux-x86_64-2.7/Crypto
copying lib/Crypto/__init__.py -> build/lib.linux-x86_64-2.7/Crypto
creating build/lib.linux-x86_64-2.7/Crypto/Hash
copying lib/Crypto/Hash/SHA.py -> build/lib.linux-x86_64-2.7/Crypto/Hash
copying lib/Crypto/Hash/__init__.py -> build/lib.linux-x86_64-2.7/Crypto/Hash
copying lib/Crypto/Hash/MD5.py -> build/lib.linux-x86_64-2.7/Crypto/Hash
copying lib/Crypto/Hash/RIPEMD.py -> build/lib.linux-x86_64-2.7/Crypto/Hash
copying lib/Crypto/Hash/HMAC.py -> build/lib.linux-x86_64-2.7/Crypto/Hash
creating build/lib.linux-x86_64-2.7/Crypto/Cipher
copying lib/Crypto/Cipher/__init__.py -> build/lib.linux-x86_64-2.7/Crypto/Cipher
creating build/lib.linux-x86_64-2.7/Crypto/Util
copying lib/Crypto/Util/_number_new.py -> build/lib.linux-x86_64-2.7/Crypto/Util
copying lib/Crypto/Util/__init__.py -> build/lib.linux-x86_64-2.7/Crypto/Util
copying lib/Crypto/Util/winrandom.py -> build/lib.linux-x86_64-2.7/Crypto/Util
copying lib/Crypto/Util/python_compat.py -> build/lib.linux-x86_64-2.7/Crypto/Util
copying lib/Crypto/Util/RFC1751.py -> build/lib.linux-x86_64-2.7/Crypto/Util …Run Code Online (Sandbox Code Playgroud) 我正在研究python,并试图从Mysql数据库中获取一些数据,以下是查询
import MySQLdb as mdb
page = 1
perpage = 3
offset = (int(page) - 1) * perpage
conn = mdb.connect(user='root', passwd='redhat', db='Python_Web', host='localhost')
cursor_posts = conn.cursor()
posts = "select * from projects LIMIT = %s OFFSET = %s " %(offset,perpage)
cursor_posts.execute(posts)
Run Code Online (Sandbox Code Playgroud)
错误:
ERROR: Internal Python error in the inspect module.
Below is the traceback from this internal error.
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/IPython/ultraTB.py", line 667, in text
locals,formatvalue=var_repr))
File "/usr/lib64/python2.7/inspect.py", line 885, in formatargvalues
specs.append(strseq(args[i], convert, join)) …Run Code Online (Sandbox Code Playgroud) 我正在尝试处理超过1GB的文本文件,并使用python将数据保存到Mysql数据库中.
我在下面粘贴了一些示例代码
import os
import MySQLdb as mdb
conn = mdb.connect(user='root', passwd='redhat', db='Xml_Data', host='localhost', charset="utf8")
file_path = "/home/local/user/Main/Module-1.0.4/file_processing/part-00000.txt"
file_open = open('part-00000','r')
for line in file_open:
result_words = line.split('\t')
query = "insert into PerformaceReport (campaignID, keywordID, keyword, avgPosition)"
query += " VALUES (%s,%s,'%s',%s) " % (result_words[0],result_words[1],result_words[2],result_words[3])
cursor = conn.cursor()
cursor.execute( query )
conn.commit()
Run Code Online (Sandbox Code Playgroud)
实际上插入数据的列数超过18列,我刚刚粘贴了四列(例如)
因此,当我运行上面的代码时,执行时间需要一些 hours
我所有的疑惑都是
编辑代码
query += " VALUES (%s,%s,'%s',%s) " % (int(result_words[0] if result_words[0] != '' else ''),int(result_words[2] if result_words[2] != '' else ''),result_words[3] …Run Code Online (Sandbox Code Playgroud) django-registration我有一个 django 应用程序并尝试在其中使用应用程序。下面是我的设置和代码
设置.py
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'south',
'registration',
'user_profile',
)
AUTH_PROFILE_MODULE = "user_profile.UserProfile"
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
)
Run Code Online (Sandbox Code Playgroud)
项目urls.py文件
urlpatterns = patterns('',
url(r'^admin/', include(admin.site.urls)),
url(r'^accounts/', include('user_profile.urls')),
url(r'^accounts/', include('registration.backends.default.urls')),
)
Run Code Online (Sandbox Code Playgroud)
user_profile urls.py文件
from registration.views import RegistrationView
urlpatterns = patterns('',
url(r'^register/$', RegistrationView.as_view(),
{'backend': 'user_profile.backends.RegistrationBackend'},
name='registration_register'),
)
Run Code Online (Sandbox Code Playgroud)
user_profile.backends.py文件
from .forms import RegistrationForm
from user_profile.models import UserProfile
from registration.views import RegistrationView
class RegistrationBackend(RegistrationView):
def get_form_class(self, request)
return RegistrationForm
def register(self, request, …Run Code Online (Sandbox Code Playgroud) 我有sql文件(single_table_data.sql)包含只有一个表的数据(我从服务器只转储了一个表)
现在我必须将此sql文件插入到我的数据库中的单个表中,
那么如何将sql文件导入到postgres中的单个表中?
编辑
例如,我有数据库名称SpeedData和表名CurrentTable,所以现在我想将整个sql文件数据插入到此表中CurrentTable
注意:sql文件只包含insert statements(甚至不包含create语句)
我有一个输入字段,如下所示
<input class="d_o" type="radio" value="super" name="old_or_new" checked="checked"> Get this value actually</input><br/>
Run Code Online (Sandbox Code Playgroud)
我必须得到输入字段的值,即,Get this value actually尝试下面的jquery代码
console.log($('.d_o').text());
Run Code Online (Sandbox Code Playgroud)
但我感到惊讶的是它没有返回任何东西,并且它试图获得价值时的工作 $('.d_o').val()
那么如何使用jquery从上面的输入字段中获取文本值我错过了什么?
python ×5
django ×1
input ×1
javascript ×1
jquery ×1
limit ×1
mysql ×1
pagination ×1
postgresql ×1
pycrypto ×1
radio ×1
restore ×1
sql-insert ×1
string ×1
text-files ×1
url ×1
user-profile ×1