PyCharm启动报错 TypeError: unsupported operand type(s) for /: ‘str’ and ‘str’ 解决
这个提示大概是说:“类型错误:不支持操作类型为字符串和字符串”,直接把两个字符串(BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))在前面定以为基础路径,也就是整个项目的路径)在列表中连接起来是不合适的,这里系统将“/”理解为了除号,系统理解为“字符串/字符串”。实际上这里想表达的意思将BASE_DIR 和’templates’连在一起形成一个完整路径,而“/”是路径分隔符。
解决方案:将settings.py中的'DIRS': [BASE_DIR / 'templates'] 修改为 'DIRS': [str.format(BASE_DIR,'/templates']
或者'DIRS': [('%s/templates') % BASE_DIR]
或者 'DIRS': [os.path.join(BASE_DIR, 'templates')] 也可以解决
PyCharm启动报错 TypeError: unsupported operand type(s) for /: ‘str’ and ‘str’ 解决的更多相关文章
- python pip install 报错TypeError: unsupported operand type(s) for -=: 'Retry' and 'int' Command "python setup.py egg_info" failed with error code 1 in
pip install http://download.pytorch.org/whl/cu80/torch-0.2.0.post3-cp27-cp27mu-manylinux1_x86_64.whl ...
- 解决pip安装时出现报错TypeError unsupported operand type(s) for -= 'Retry' and 'int'
1.参考 https://stackoverflow.com/questions/42610545/typeerror-unsupported-operand-types-for-retry-and- ...
- python TypeError: unsupported operand type(s) for +: 'int' and 'str' [closed]
TypeError: unsupported operand type(s) for +: 'int' and 'str' [closed] sql="insert into auto_tr ...
- TypeError: unsupported operand type(s) for +: 'float' and 'decimal.Decimal'
TypeError: unsupported operand type(s) for +: 'float' and 'decimal.Decimal' 浮点型和双精度类型 相加报错 from deci ...
- python3.x元组打印错误 TypeError: unsupported operand type(s) for %: 'NoneType' and 'tuple'
原创by南山南北秋悲 欢迎引用!请注明原地址:http://www.cnblogs.com/hwd9654/p/5676746.html 谢谢! TypeError: unsupported ope ...
- python TypeError: unsupported operand type(s) for +: 'geoprocessing value object' and 'str'
TypeError: unsupported operand type(s) for +: 'geoprocessing value object' and 'str' if self.params[ ...
- tomcat启动报错:Unsupported major.minor version 51.0
myeclipse中添加项目后,发现项目启动时报错:Unsupported major.minor version 51.0 因为tomcat使用的jdk版本不支持你项目的jdk版本,需要你在myec ...
- python2.7 使用super关键词 报错 TypeError: must be type, not&n
错误试验代码: class Base(): def meth(self): print "i'm base" class Derived(Base): def meth(self) ...
- python 报错TypeError: 'range' object does not support item assignment,解决方法
贴问题 nums = range(5)#range is a built-in function that creates a list of integers print(nums)#prints ...
随机推荐
- elf文件结构解读以及plt节got节的理解
前言: 熟悉elf文件结构是一件很不错的事,因为安卓中的so加固以及修复都是需要这些知识的,包括pwn里面的rop之类的,也都是 和got节,plt节息息相关的,个人建议是在搞懂elf文件结构后,自己 ...
- Serverless与Web后端天生不合?
Serverless/Faas/BaaS 等概念在这几年的技术圈中是绝对的热点词汇之一,国内外众多云厂商也纷纷推出自家的 Serverless 和函数计算产品,微信也依托腾讯云推出了基于 Server ...
- C语言:3个数排序
#include <stdio.h> int main() { int a,b,c,t; /*定义4个基本整型变量a.b.c.t*/ printf("Please input a ...
- C语言:读写TXT
fopen() 改为: if((fp=fopen("1s.txt","w+"))==NULL) fputc(p,fp); 改为:fprintf(fp," ...
- win10 IIS web.config加密不能访问:打不开 RSA 密钥容器
C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys 找到密钥文件, 根据时间判断具体是哪一个文件,赋予network service读权限
- [004] .NET 的现状和未来
我们总是能听到一些人说,.NET 不行.学 .NET 没发展前途之类的言论,有的童鞋听多了便也开始怀疑自己选择的 .NET 方向是不是错了. 不得不承认,在 .NET 没有实现跨平台之前,市场行情确实 ...
- 如何访问网络损伤仪WANsim的控制界面
一台全新的WANsim网络损伤仪的默认IP地址为192.168.1.199.网络损伤仪的控制界面部署在 8080 端口. 所以,我们在成功连接了WANsim之后,只需要在控制电脑上打开谷歌浏览器,访问 ...
- py3射击小游戏
关于py3面向对象的小Demo,欢迎 交流. class Person(object):#声明人类 def __init__(self,name): self.name = name self.gun ...
- 开源低代码平台开发实践二:从 0 构建一个基于 ER 图的低代码后端
前后端分离了! 第一次知道这个事情的时候,内心是困惑的. 前端都出去搞 SPA,SEO 们同意吗? 后来,SSR 来了. 他说:"SEO 们同意了!" 任何人的反对,都没用了,时代 ...
- 构建前端第8篇之---Webstom搭建ES6运行环境
张艳涛 写于2021-1-22 一.在有webstorm和node.js前提下,安装全局的babel npm install babel-cli babel-eslint -g 二.在terminal ...