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 ...
随机推荐
- 微信小程序支付 后台处理逻辑 (转)
<?phpnamespace app\parent\controller; use think\Request; class Wxpay{ function wechat(){ //微信配 ...
- php微信jsapi支付 支付宝支付 两码合一
产品开会提出了这样的需求:一个二维码可以微信支付也可以支付宝支付 经过自己的钻研以及询问技术高人(本人代码一般般)和网上搜索 最终实现其功能 我用微信jsapi 和 支付宝网页支付 其实并不怎么难: ...
- C语言代码段
/* 功 能:将str字符串中的oldstr字符串替换为newstr字符串 * 参 数:str:操作目标 oldstr:被替换者 newstr:替换者 * 返回值:返回替换之后的字符串 */ char ...
- 远程cmd操作
<<PSTools.zip>><<Install_PowerCmd.exe>><<cmder_mini.zip>><< ...
- 前端-Vue基础3(父子组件交互)
1.子组件往父组件传值 点击子组件的值,子组件自增,父组件的值也跟着自增 通过:this.$emit('change')方法向父组件暴露事件,在子组件中引用,可以调用父组件的方法 点击子组件触发cli ...
- Linux相关网络命令大全 网络接口 域名分析
Linux网络设置一.查看网络接口信息ifconfig① 查看所有活动的网络接口信息② 查看指定网络接口信息补充二.查看主机名称hostname① hostname命令② 永久设置主机名三.查看路由表 ...
- 如何在Apache HttpClient中设置TLS版本
1.简介 Apache HttpClient是一个底层.轻量级的客户端HTTP库,用于与HTTP服务器进行通信. 在本教程中,我们将学习如何在使用HttpClient时配置支持的传输层安全(TLS)版 ...
- C语言:数组长度的检测方法
//数组长度的检测方法 #include <stdio.h> int main() { int arr[] = { 22, 34, 3, 32, 82, 55, 89, 50, 37, 5 ...
- 检测当前手机正在运行的APP
import re #一定要引入,否则不提示错误,但找不到目标def jiance(sjh): aakk="adb -s {0} shell dumpsys activity activit ...
- asp.net c#从SQL2008读取图片显示到网页
//图像数据表:tx//字段id (nvarchar(50) ,image(image)//tgav为图片ID,实质为上传前的主名 (省略了.jpg) using System; using Syst ...