小编Ale*_*lex的帖子

Python3添加日志记录级别

我有这个代码对我来说很好.

import logging
import logging.handlers

logger = None


def create_logger():
    global logger
    logger = logging.getLogger('Logger')
    logger.setLevel(logging.DEBUG)
    handler = logging.handlers.RotatingFileHandler("C:/Users/user/Desktop/info.log", maxBytes=1000000, backupCount=20)
    formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
    handler.setFormatter(formatter)
    logger.addHandler(handler)


create_logger()
logger.info("Text info")
logger.debug("Text debug")
logger.warning("Text warning")
logger.error("Text error")
logger.critical("Text critical")
Run Code Online (Sandbox Code Playgroud)

输出看起来很棒:

2017-12-19 15:06:43,021 - 记录器 - 信息 - 文本信息
2017-12-19 15:06:43,021 - 记录器 - 调试 - 文本调试
2017-12-19 15:06:43,022 - 记录器 - 警告 - 正文警告
2017-12-19 15:06:43,022 - 记录器 - 错误 - 文本错误
2017-12-19 15:06:43,022 - 记录器 …

python logging python-3.5

7
推荐指数
1
解决办法
3031
查看次数

如何在c中划分2 int?

想要划分2个数字,得到如下结果:

5/2 = 2.50

但它只输出2.

我现在不知道我做错了什么.

这是我的代码:

int a;
int b;
int c;
printf("First num\n");
scanf("%d", &a);
printf("Second num\n");
scanf("%d", &b);
c = a / b;
printf("%d", c);
Run Code Online (Sandbox Code Playgroud)

c division

4
推荐指数
1
解决办法
6万
查看次数

创建不编码的查询字符串

我想创建一个查询字符串,但不编码特殊字符,例如@,!?

这是我的代码:

payload = {"key": "value", "key2": "value2",
           "email": "test@hello3.ch", "password": "myPassword54321!?"}
print(urllib.parse.urlencode(payload))  
Run Code Online (Sandbox Code Playgroud)

现在我得到的输出是:

密码=myPassword54321%21%3F&email=test%40hello3.ch

我怎样才能使我的输出看起来像这样:

密码=myPassword54321!?&email=test@hello3.ch

urllib urlencode python-3.x

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

Redis-py是否支持unicode和utf-8以及它是如何工作的

我是redis的新手,我想知道redis-py是否支持unicode和utf-8.
我想我们也可以编码和解码,但我不知道如何.
假设我在redis中输入一个值:'ü'.
然后我会得到这个输出:'\ xc3\xbc'

有人可以解释我这个过程

谢谢

python unicode utf-8 redis

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

标签 统计

python ×2

c ×1

division ×1

logging ×1

python-3.5 ×1

python-3.x ×1

redis ×1

unicode ×1

urlencode ×1

urllib ×1

utf-8 ×1