Skip to content
yihong0618's Blog
Go back

踩坑小记

Updated:

Originally published as GitHub issue #10.

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))

Reactions

👍 1

Comments

yihong0618

View comment · 2019-08-04T15:17:58Z

2019.08.04

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

妈的解决了2个小时

yihong0618

View comment · 2019-08-11T15:23:04Z

2019.08.11


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

yihong0618

View comment · 2019-09-09T07:03:50Z

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

yihong0618

View comment · 2019-09-09T08:49:37Z

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

yihong0618

View comment · 2019-09-18T09:31:44Z

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

yihong0618

View comment · 2019-09-19T05:19:40Z

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

yihong0618

View comment · 2019-09-23T15:23:26Z

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

yihong0618

View comment · 2019-09-24T00:48:35Z

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

yihong0618

View comment · 2019-09-24T09:05:17Z

生成requirements的包 pip3 freeze >requirements.txt

yihong0618

View comment · 2019-10-02T04:55:21Z

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

yihong0618

View comment · 2019-10-07T06:54:18Z

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

yihong0618

View comment · 2019-10-07T06:55:05Z

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

yihong0618

View comment · 2019-10-07T06:56:34Z

f-string调试?

yihong0618

View comment · 2020-08-14T01:02:04Z

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



Previous Post
番茄工作法,焦虑,咖啡,喘不上气,生活
Next Post
迷茫,又一次重新学日语