Merged
Conversation
dataabc
reviewed
Dec 13, 2021
weibo_spider/parser/util.py
Outdated
| def string_to_int(string): | ||
| """字符串转换为整数""" | ||
| if len(string) == 0: | ||
| print("Warning: the input string is empty!") |
Owner
There was a problem hiding this comment.
感谢贡献代码,个人认为这里print改成logger.warning更好一点,因为方便写日志。如果有不同看法,欢迎讨论。
Contributor
Author
There was a problem hiding this comment.
@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.)
Owner
There was a problem hiding this comment.
string_to_int是将字符串转化数字的,微博评论点赞等的数量有时会包含'万'等,需要转化成数字。您的意思是要在这个方法内添加个是否成功的返回值,还是添加个参数告诉本方法?我不了解qt,搜索了一下,发现是可视化工具,qt的规范是要这样吗?期待您的解答,感谢。
Owner
|
感谢贡献代码,已merge。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
修复用户uid等于1时,会crash问题