我有这个代码对我来说很好.
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 - 记录器 …
想要划分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) 我想创建一个查询字符串,但不编码特殊字符,例如@,!或?。
这是我的代码:
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
我是redis的新手,我想知道redis-py是否支持unicode和utf-8.
我想我们也可以编码和解码,但我不知道如何.
假设我在redis中输入一个值:'ü'.
然后我会得到这个输出:'\ xc3\xbc'
有人可以解释我这个过程
谢谢