Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

踩坑小记 #10

Open
yihong0618 opened this issue Jul 28, 2019 · 14 comments
Open

踩坑小记 #10

yihong0618 opened this issue Jul 28, 2019 · 14 comments
Labels
技术文章 技术文章

Comments

@yihong0618
Copy link
Owner

yihong0618 commented Jul 28, 2019

2019.7.28

  1. Python requests post传data要传json而不是dict
  2. Go项目在github克隆下来的话可以直接clone在gopath里,甚至可以直接用go get这样会方便很多

2019.7.29

  1. Windows, Linux, Mac会有路径问题,要多使用pathlib
root = Path("../PycharmProject")
config_dir = root/Path("config")
# 等价于config_dir = os.path.join(root, 'config')
print(str(config_dir))
config.files = config_dir.rglob("*.json")
  1. 读取文件时要加上rb 避免文字格式问题
with open(filename, encoding='utf-8', mode =r') as f:
    for line in f:
        print(repr(line))
@yihong0618
Copy link
Owner Author

yihong0618 commented Aug 4, 2019

2019.08.04

python setup.py问题
install后装在site-packags里
所以无论怎么改本地文件都是没用的
打包过后记得改版本才生效

妈的解决了2个小时

@yihong0618
Copy link
Owner Author

2019.08.11


  1. pymongo返回的是生成器,需要迭代
  2. 有时候网络问题很可能是localhost和127.0.0.1的问题
@yihong0618
Copy link
Owner Author

flask应用测试时打开端口
iptables -I INPUT -p tcp --dport 5000 -j ACCEPT

@yihong0618
Copy link
Owner Author

干掉uwsgi进程
killall -s INT /usr/local/bin/uwsgi

@yihong0618
Copy link
Owner Author

  1. 对数字不要想当然的取值,要考虑正则.
  2. 拼接路径或者用split “/“ 一定要考虑平台问题
    gunicorn --worker-class eventlet -w 1 log_server:app -b 0.0.0.0:5000 --daemon
  3. 不能想当然的用&后台启动,要看情况用--daemon
@yihong0618
Copy link
Owner Author

  1. 避免不同操作系统等因素,不管什么时候都要加encoding
  2. path同理,永远不要用"/"拼接路径
  3. 处理编码时可以加入ignore
@yihong0618
Copy link
Owner Author

发布到pypi看这篇文章--发布
用twine发布
发布前一定要删除之前的

@yihong0618
Copy link
Owner Author

Python和mysql交互的时候,一定多考虑数据格式

@yihong0618
Copy link
Owner Author

生成requirements的包
pip3 freeze >requirements.txt

@yihong0618
Copy link
Owner Author

阿里云端口需要增加安全组配置

@yihong0618 yihong0618 added the 技术文章 技术文章 label Oct 2, 2019
@yihong0618
Copy link
Owner Author

处理json数据一定要看清层级

@yihong0618
Copy link
Owner Author

调试时候一定要稳准狠,耐性

@yihong0618
Copy link
Owner Author

f-string调试?

@yihong0618
Copy link
Owner Author

有可能只是差一个括号,一定要冷静debug的时候。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
技术文章 技术文章
1 participant