小编Bou*_*h10的帖子

Sublime文本中的白色文本

我从他们的网站下载了Sublime文本,我的代码仍然是白色,我不知道为什么.我unistalled并重新安装它3次,试图安装主题包等我不明白有什么不对.

在此输入图像描述

colors sublimetext sublimetext2

5
推荐指数
1
解决办法
6483
查看次数

IOError:[Errno 2]没有这样的文件或目录

我试图在我的MySQL数据库的表的路径中添加所有种子文件的一些信息,但似乎我有一些PATH问题.你可以看到有完整的路径,它甚至检测到"charlie.torrent",所以我真的不明白是什么问题.

这是我的代码:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import mysql.connector
import bencode
import binascii
import hashlib
import os
import sys

conn = mysql.connector.connect(host="localhost",user="root",password="root", database="TORRENTS")
cursor = conn.cursor
path = "/home/florian/TorrentFiles"
dirs = os.listdir(path)
for file in dirs:
        try:
                with open(file, 'rb') as torrentfile:
                        torrent = bencode.bdecode(torrentfile.read())
                        user = ("torrent['info']['name']","torrent['info']['length'],'bytes'","(hashlib.sha1(bencode.bencode(torrent['info'])).hexdigest())")
                        cursor.execute("""INSERT INTO torrent_infos (Name, Size, Hash) VALUES(%s, %s, %s)""", user)
        except bencode.BTL.BTFailure:
                continue


conn.close()
Run Code Online (Sandbox Code Playgroud)

我真的不明白我的脚本的以下输出:

root@debian:/home/florian/Documents/mysite/polls# python bdd.py 
Traceback (most recent call last):
  File "bdd.py", line 17, in <module>
    with …
Run Code Online (Sandbox Code Playgroud)

python path ioerror python-2.7

2
推荐指数
1
解决办法
3050
查看次数

ProgrammingError:字符串格式化过程中的参数数量错误

我正在尝试将列表中的一些数据主动放入表中的数据库中polls_ip.然而,似乎存在一些争论的问题可能是由于我想要放入的数据类型.

如果你想看看我的代码中有用的部分:

fin_flag = ( tcp.flags & dpkt.tcp.TH_FIN ) != 0
rst_flag = ( tcp.flags & dpkt.tcp.TH_RST ) != 0

if fin_flag or rst_flag:
    src_ip2 = socket.inet_ntoa(ip.src)
    dst_ip2 = socket.inet_ntoa(ip.dst)
    for element in liste:
        if element == (src_ip2+" "+dst_ip2) or element == (dst_ip2+" "+src_ip2):
            liste.remove(element)

            cursor.execute("INSERT INTO polls_ip (Ip) VALUES (%s)", (element))
Run Code Online (Sandbox Code Playgroud)

问题可能来自内线cursor.execute 看看输出:

Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 552, in __bootstrap_inner
    self.run()
  File "scriptbdd.py", line 134, in run
    self.p.dispatch(0, …
Run Code Online (Sandbox Code Playgroud)

python mysql python-2.7

2
推荐指数
1
解决办法
1072
查看次数

模板Django(不存在于/)

我正在尝试使用Django模板,但我甚至无法显示一个简单的html行,我不明白为什么...我搜索解决它但经过多次测试后,问题仍然存在.

这是我的结构:

在此输入图像描述

我的urls.py(我使用views.py中的另一个函数尝试了它):

from django.conf.urls import patterns,include, url
from django.contrib import admin

urlpatterns = patterns('polls.views',

         url(r'^$', 'home', name = 'home'),
         url(r'^admin/', include(admin.site.urls)),
)
Run Code Online (Sandbox Code Playgroud)

我的views.py:

from django.shortcuts import render
from django.template import Template , Context

# Create your views here.
# -*- coding: utf-8 -*-

def home(request):
    return render(request, 'mysite/bap2pmonitoring.html')
Run Code Online (Sandbox Code Playgroud)

我的设置文件setting.py:

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'templates'],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]
Run Code Online (Sandbox Code Playgroud)

我简单的HTML文档:

<h1> BAP2P Monitoring </h1>
Run Code Online (Sandbox Code Playgroud)

输出最后是我的主要问题:

在此输入图像描述

这是追溯: …

python django templates views django-templates

0
推荐指数
2
解决办法
6580
查看次数