Skip to content

Comments

fix: when uid==1 then crash#401

Merged
dataabc merged 3 commits intodataabc:masterfrom
minami9:master
Dec 14, 2021
Merged

fix: when uid==1 then crash#401
dataabc merged 3 commits intodataabc:masterfrom
minami9:master

Conversation

@minami9
Copy link
Contributor

@minami9 minami9 commented Dec 13, 2021

修复用户uid等于1时,会crash问题

def string_to_int(string):
"""字符串转换为整数"""
if len(string) == 0:
print("Warning: the input string is empty!")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感谢贡献代码,个人认为这里print改成logger.warning更好一点,因为方便写日志。如果有不同看法,欢迎讨论。

Copy link
Contributor Author

@minami9 minami9 Dec 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dataabc
emm..I think the function named string_to_int is not good.
Because of there is no flag to notify caller that inputted string is right or not.
Maybe need like this(ref to libc):

import string 
string.atoi(covert_string)

I don't know why not use the function we had, but according to Qt, there have a *ok to notify that convert progress have not error occurred.

int QString::toInt(const QString &covert_string, bool *ok)

and, the logger.warning is better than current solution, I will modify it and push again later.)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

string_to_int是将字符串转化数字的,微博评论点赞等的数量有时会包含'万'等,需要转化成数字。您的意思是要在这个方法内添加个是否成功的返回值,还是添加个参数告诉本方法?我不了解qt,搜索了一下,发现是可视化工具,qt的规范是要这样吗?期待您的解答,感谢。

@dataabc dataabc merged commit 7730543 into dataabc:master Dec 14, 2021
@dataabc
Copy link
Owner

dataabc commented Dec 14, 2021

感谢贡献代码,已merge。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants